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
62
63
|
#include "mainMenu.h"
#include "game.h"
#include "assets.h"
void initMainMenu(MainMenu* mainMenu, Game* game)
{
// Start button stuff.
mainMenu->startButtonAnimation = createAnimation(
&game->assets.animations[BUTTON_BOX_ANIMATION],
ANIMATION_DEFAULT_DELAY
);
playAnimation(&mainMenu->startButtonAnimation);
Texture* startButtonTexture = &mainMenu->startButtonAnimation.texture;
int width = GetScreenWidth();
int height = GetScreenHeight();
mainMenu->startButton = createTexturedButton(
startButtonTexture,
(Rectangle){
width / 2.0 - startButtonTexture->width / 2.0,
height / 2.0 - startButtonTexture->height,
startButtonTexture->width,
startButtonTexture->height
},
"Start",
WHITE,
BLACK
);
mainMenu->startButton.fontSize = 50;
}
void updateMainMenu(MainMenu* mainMenu, Game* game)
{
// Draw background.
Texture background = game->assets.textures[PENGUIN_BACKGROUND_TEXTURE];
DrawTexturePro(
background,
(Rectangle){0.0, 0.0, background.width, background.height},
(Rectangle){0.0, 0.0, GetScreenWidth(), GetScreenHeight()},
(Vector2){0.0, 0.0},
0.0,
WHITE
);
// Draw start button.
runAnimation(&mainMenu->startButtonAnimation);
bool startPressed = updateTexturedButton(&mainMenu->startButton);
if (startPressed)
{
game->currentScreen = GAME_SCREEN;
}
}
void closeMainMenu(MainMenu* mainMenu)
{
closeAnimation(&mainMenu->startButtonAnimation);
}
|