summaryrefslogtreecommitdiff
path: root/src/scenes/menu_scene.c
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2024-11-23 21:52:24 +0100
committerAldrik Ramaekers <aldrikboy@gmail.com>2024-11-23 21:52:24 +0100
commit6f7374c2fa58c8692b51018864b802e6b876d305 (patch)
treea7e8ead757e9f4de1920395336dcac1c8a989576 /src/scenes/menu_scene.c
A new start
Diffstat (limited to 'src/scenes/menu_scene.c')
-rw-r--r--src/scenes/menu_scene.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/scenes/menu_scene.c b/src/scenes/menu_scene.c
new file mode 100644
index 0000000..73ec22d
--- /dev/null
+++ b/src/scenes/menu_scene.c
@@ -0,0 +1,93 @@
+
+void menu_scene_init()
+{
+
+}
+
+static void menu_draw_background(platform_window* window)
+{
+ vec4 area = camera_get_target_rectangle(window);
+ renderer->render_rectangle(area.x, area.y, area.w, area.h, COLOR_WORLD_MAP_BACKGROUND);
+ renderer->render_image(img_world_map, area.x, area.y, area.w, area.h);
+}
+
+static void menu_draw_options(platform_window* window)
+{
+ s32 screen_center_x = area.x + (area.w/2);
+ s32 screen_center_y = area.y + (area.h/2);
+
+ s32 panel_w = 198 * scale;
+ s32 panel_h = 193 * scale;
+ s32 panel_x = screen_center_x - (panel_w/2);
+ s32 panel_y = screen_center_y - (panel_h/2);
+ panel_render(scale, panel_x, panel_y, panel_w, panel_h);
+
+ s32 button_w = 178 * scale;
+ s32 button_h = 37 * scale;
+ s32 vertical_pad = 10 * scale;
+ s32 pad_x = (panel_w - button_w)/2;
+ float pad_y = (panel_h - (vertical_pad*2) - button_h*4)/5.0f;
+
+ if (button_render(scale, BUTTON_ENABLED, "New Game", panel_x + pad_x, vertical_pad + panel_y + pad_y*1, button_w, button_h))
+ {
+ start_loading_world(0); // Start new world
+ }
+
+ if (button_render(scale, BUTTON_ENABLED, "Continue", panel_x + pad_x, vertical_pad + panel_y + pad_y*2 + button_h*1, button_w, button_h))
+ {
+ game_set_active_scene(GAME_STATE_SELECT_SAVE);
+ }
+
+ if (button_render(scale, BUTTON_ENABLED, "Settings", panel_x + pad_x, vertical_pad + panel_y + pad_y*3 + button_h*2, button_w, button_h))
+ {
+ game_set_active_scene(GAME_STATE_SETTINGS);
+ }
+
+ if (button_render(scale, BUTTON_ENABLED, "Quit", panel_x + pad_x, vertical_pad + panel_y + pad_y*4 + button_h*3, button_w, button_h))
+ {
+ window->is_open = false;
+ }
+}
+
+static void menu_draw_title(platform_window* window)
+{
+ s32 panel_w = 198 * scale;
+ s32 panel_h = 70 * scale;
+ s32 panel_pad = 50 * scale;
+ s32 panel_x = area.x + panel_pad;
+ s32 panel_y = area.y + area.h - panel_h - panel_pad;
+ panel_render(scale, panel_x, panel_y, panel_w, panel_h);
+
+ font* font_reg = FONT_REGULAR(SIZE_RD(area.w, 44));
+ font* font_sml = FONT_REGULAR(SIZE_RD(area.w, 20));
+ s32 text_pad = 5*scale;
+ s32 total_text_h = font_reg->px_h + text_pad + font_sml->px_h;
+ s32 text_y = panel_y + (panel_h/2) - (total_text_h/2);
+ char* game_title = "TruckerX";
+ char* game_version = "rev "GAME_VERSION;
+ s32 game_title_width = renderer->calculate_text_width(font_reg, game_title);
+ s32 text_x = panel_x + (panel_w/2) - (game_title_width/2);
+
+ renderer->render_text(font_reg, text_x+2, text_y+2, game_title, COLOR_TEXT_SHADOW);
+ renderer->render_text(font_reg, text_x, text_y, game_title, COLOR_TEXT);
+
+ renderer->render_text(font_sml, 10*scale + text_x+2,font_reg->px_h + text_pad + text_y+2, game_version, COLOR_TEXT_SHADOW);
+ renderer->render_text(font_sml, 10*scale + text_x, font_reg->px_h + text_pad + text_y, game_version, COLOR_TEXT);
+}
+
+void menu_scene_render(platform_window* window)
+{
+ menu_draw_background(window);
+ menu_draw_options(window);
+ menu_draw_title(window);
+}
+
+void menu_scene_update(platform_window* window)
+{
+
+}
+
+void menu_scene_destroy()
+{
+
+} \ No newline at end of file