diff options
Diffstat (limited to 'menu.c')
| -rw-r--r-- | menu.c | 39 |
1 files changed, 39 insertions, 0 deletions
| @@ -0,0 +1,39 @@ | |||
| 1 | #include "all.h" | ||
| 2 | |||
| 3 | void UpdateMenu(void) { | ||
| 4 | if (IsKeyPressed(KEY_ENTER)) { | ||
| 5 | if (LoadMap(game.map_path)) { | ||
| 6 | game.mode = STATE_PLAYING; | ||
| 7 | game.cursor_captured = true; | ||
| 8 | DisableCursor(); | ||
| 9 | } | ||
| 10 | } | ||
| 11 | } | ||
| 12 | |||
| 13 | void DrawMenu(void) { | ||
| 14 | BeginDrawing(); | ||
| 15 | ClearBackground(BLACK); | ||
| 16 | |||
| 17 | int screenWidth = GetScreenWidth(); | ||
| 18 | int screenHeight = GetScreenHeight(); | ||
| 19 | |||
| 20 | const char *title = "STALAG"; | ||
| 21 | const char *sub = "Press ENTER to Start"; | ||
| 22 | |||
| 23 | int titleSize = 60; | ||
| 24 | int subSize = 20; | ||
| 25 | |||
| 26 | Vector2 titlePos = { | ||
| 27 | (float)(screenWidth - MeasureTextEx(game.font_ui, title, (float)titleSize, 4).x) / 2, | ||
| 28 | (float)screenHeight / 2 - 40 | ||
| 29 | }; | ||
| 30 | Vector2 subPos = { | ||
| 31 | (float)(screenWidth - MeasureTextEx(game.font_ui, sub, (float)subSize, 2).x) / 2, | ||
| 32 | (float)screenHeight / 2 + 40 | ||
| 33 | }; | ||
| 34 | |||
| 35 | DrawTextEx(game.font_ui, title, titlePos, (float)titleSize, 4, WHITE); | ||
| 36 | DrawTextEx(game.font_ui, sub, subPos, (float)subSize, 2, GRAY); | ||
| 37 | |||
| 38 | EndDrawing(); | ||
| 39 | } | ||
