|
@@ -1,7 +1,6 @@
|
|
|
-#include <stdio.h>
|
|
|
|
|
-
|
|
|
|
|
#include "scufeng/engine.h"
|
|
#include "scufeng/engine.h"
|
|
|
#include "scufeng/Mesh.h"
|
|
#include "scufeng/Mesh.h"
|
|
|
|
|
+#include "scufeng/log.h"
|
|
|
#include "cglm/vec3.h"
|
|
#include "cglm/vec3.h"
|
|
|
|
|
|
|
|
#include "MainMenu.h"
|
|
#include "MainMenu.h"
|
|
@@ -12,7 +11,7 @@ MainMenu MainMenu_alloc(const unsigned int screen_w, const unsigned int screen_h
|
|
|
|
|
|
|
|
mm.title_text = SEMesh_string_alloc("Pong", 1.0f, GLM_VEC3_ONE);
|
|
mm.title_text = SEMesh_string_alloc("Pong", 1.0f, GLM_VEC3_ONE);
|
|
|
mm.title_text.transform.pos[0] = screen_w / 2.0f;
|
|
mm.title_text.transform.pos[0] = screen_w / 2.0f;
|
|
|
- mm.title_text.transform.pos[1] = screen_h * 0.8f;
|
|
|
|
|
|
|
+ mm.title_text.transform.pos[1] = screen_h * 0.2f;
|
|
|
|
|
|
|
|
mm.sp_text = SEMesh_string_alloc("Singleplayer", 1.0f, GLM_VEC3_ONE);
|
|
mm.sp_text = SEMesh_string_alloc("Singleplayer", 1.0f, GLM_VEC3_ONE);
|
|
|
mm.sp_text.transform.pos[0] = screen_w * 0.25f;
|
|
mm.sp_text.transform.pos[0] = screen_w * 0.25f;
|
|
@@ -22,6 +21,10 @@ MainMenu MainMenu_alloc(const unsigned int screen_w, const unsigned int screen_h
|
|
|
mm.mp_text.transform.pos[0] = screen_w - mm.sp_text.transform.pos[0];
|
|
mm.mp_text.transform.pos[0] = screen_w - mm.sp_text.transform.pos[0];
|
|
|
mm.mp_text.transform.pos[1] = mm.sp_text.transform.pos[1];
|
|
mm.mp_text.transform.pos[1] = mm.sp_text.transform.pos[1];
|
|
|
|
|
|
|
|
|
|
+ mm.quit_text = SEMesh_string_alloc("Quit", 1.0f, GLM_VEC3_ONE);
|
|
|
|
|
+ mm.quit_text.transform.pos[0] = screen_w / 2.0f;
|
|
|
|
|
+ mm.quit_text.transform.pos[1] = screen_h * 0.8f;
|
|
|
|
|
+
|
|
|
return mm;
|
|
return mm;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -31,14 +34,19 @@ static Screen MainMenu_input_handle(MainMenu *const mm) {
|
|
|
se_get_mouse_pos(&x, &y);
|
|
se_get_mouse_pos(&x, &y);
|
|
|
|
|
|
|
|
if (SEMesh_rect_is_pos_inside(&mm->sp_text, x, y)) {
|
|
if (SEMesh_rect_is_pos_inside(&mm->sp_text, x, y)) {
|
|
|
- printf("SP\n");
|
|
|
|
|
|
|
+ SE_LOG("SP");
|
|
|
return PONG_SINGLEPLAYER;
|
|
return PONG_SINGLEPLAYER;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (SEMesh_rect_is_pos_inside(&mm->mp_text, x, y)) {
|
|
if (SEMesh_rect_is_pos_inside(&mm->mp_text, x, y)) {
|
|
|
- printf("MP\n");
|
|
|
|
|
|
|
+ SE_LOG("MP");
|
|
|
return PONG_MULTIPLAYER;
|
|
return PONG_MULTIPLAYER;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (SEMesh_rect_is_pos_inside(&mm->quit_text, x, y)) {
|
|
|
|
|
+ SE_LOG("Quit");
|
|
|
|
|
+ se_window_close();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return PONG_MAIN_MENU;
|
|
return PONG_MAIN_MENU;
|
|
@@ -49,10 +57,11 @@ Screen MainMenu_tick(MainMenu *const mm) {
|
|
|
if (screen != PONG_MAIN_MENU) {
|
|
if (screen != PONG_MAIN_MENU) {
|
|
|
return screen;
|
|
return screen;
|
|
|
}
|
|
}
|
|
|
- const SEMesh *meshes[] = {
|
|
|
|
|
|
|
+ SEMesh *meshes[] = {
|
|
|
&mm->title_text,
|
|
&mm->title_text,
|
|
|
&mm->sp_text,
|
|
&mm->sp_text,
|
|
|
- &mm->mp_text
|
|
|
|
|
|
|
+ &mm->mp_text,
|
|
|
|
|
+ &mm->quit_text
|
|
|
};
|
|
};
|
|
|
SEMesh_render_multiple_2d(meshes, sizeof(meshes) / sizeof(meshes[0]));
|
|
SEMesh_render_multiple_2d(meshes, sizeof(meshes) / sizeof(meshes[0]));
|
|
|
|
|
|