From b4d0ad9e95226d225d5361b1182866884aaa6366 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Thu, 30 Apr 2026 19:19:27 +0200 Subject: Structural refactor --- menu.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 menu.c (limited to 'menu.c') diff --git a/menu.c b/menu.c new file mode 100644 index 0000000..c1db1f7 --- /dev/null +++ b/menu.c @@ -0,0 +1,39 @@ +#include "all.h" + +void UpdateMenu(void) { + if (IsKeyPressed(KEY_ENTER)) { + if (LoadMap(game.map_path)) { + game.mode = STATE_PLAYING; + game.cursor_captured = true; + DisableCursor(); + } + } +} + +void DrawMenu(void) { + BeginDrawing(); + ClearBackground(BLACK); + + int screenWidth = GetScreenWidth(); + int screenHeight = GetScreenHeight(); + + const char *title = "STALAG"; + const char *sub = "Press ENTER to Start"; + + int titleSize = 60; + int subSize = 20; + + Vector2 titlePos = { + (float)(screenWidth - MeasureTextEx(game.font_ui, title, (float)titleSize, 4).x) / 2, + (float)screenHeight / 2 - 40 + }; + Vector2 subPos = { + (float)(screenWidth - MeasureTextEx(game.font_ui, sub, (float)subSize, 2).x) / 2, + (float)screenHeight / 2 + 40 + }; + + DrawTextEx(game.font_ui, title, titlePos, (float)titleSize, 4, WHITE); + DrawTextEx(game.font_ui, sub, subPos, (float)subSize, 2, GRAY); + + EndDrawing(); +} -- cgit v1.2.3