-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainMenu.c
61 lines (48 loc) · 2.35 KB
/
mainMenu.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*******************************************************************************************
*
* Smurf Invaders. Technical Demo as an explorative project of Raylib.
* Random game based on Space Invaders and alike.
*
* Copyright (c) 2020 Oscar Lostes Cazorla, under MIT license.
*
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* Raylib by Ramon Santamaria (@raysan5), Copyright (c) 2013-2020
*
********************************************************************************************/
#include "mainMenu.h"
State mainMenu()
{
// Initialization
//--------------------------------------------------------------------------------------
// Initaize HUD displays
//TextCopy(healthDisp, TextFormat("LIVES: %d", health));
//TextCopy(scoreDisp, TextFormat("SCORE: %d", score));
SetExitKey(KEY_ESCAPE);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key. Dummy exit on player killed
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_ENTER)) return GAME;
if (IsKeyPressed(KEY_S)) return SCORE_M;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
{
ClearBackground(RAYWHITE); // Clear background
// Menu drawing
DrawText("SMURF INVADERS", screenWidth / 2 - MeasureText("SMURF INVADERS", 40) / 2, screenHeight / 2 - 10, 40, DARKGREEN);
DrawText("Press ENTER to start", screenWidth / 2 - MeasureText("Press ENTER to start", 20) / 2, screenHeight / 2 + 50, 20, BLUE);
DrawText("Press S to see the scoreboard", screenWidth / 2 - MeasureText("Press S to see the scoreboard", 20) / 2, screenHeight / 2 + 90, 20, BLUE);
DrawText("Press ESC to quit", screenWidth / 2 - MeasureText("Press ESC to quit", 20) / 2, screenHeight / 2 + 130, 20, BLUE);
}
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
return EXIT;
}