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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#include "gameScreen.h"
#include "game.h"
#include "assets.h"
void initGameScreen(GameScreen* gameScreen, Game* game)
{
Assets* assets = &game->assets;
int width = GetScreenWidth();
int height = GetScreenHeight();
int navigationButtonSize = 100;
int navigationButtonX = width - navigationButtonSize - 5.0;
// Navigation buttons.
gameScreen->toGameButton = createTexturedButton(
&assets->textures[TO_GAME_ICON_TEXTURE],
(Rectangle){navigationButtonX, 5.0, navigationButtonSize, navigationButtonSize},
"",
WHITE,
BLACK
);
gameScreen->toEmperorsEmporiumButton = createTexturedButton(
&assets->textures[TO_EMPERORS_EMPORIUM_ICON_TEXTURE],
(Rectangle){navigationButtonX, navigationButtonSize + 15.0, navigationButtonSize, navigationButtonSize},
"",
WHITE,
BLACK
);
// Button pannel thingy.
gameScreen->buttonPanelSharedAnimation = createAnimation(&assets->animations[BUTTON_BOX_ANIMATION], ANIMATION_DEFAULT_DELAY);
playAnimation(&gameScreen->buttonPanelSharedAnimation);
Texture* buttonTexture = &gameScreen->buttonPanelSharedAnimation.texture;
int buttonWidth = width / 4;
int buttonHeight = buttonWidth / 2.0;
int buttonY = height - buttonHeight;
gameScreen->upgradesButton = createTexturedButton(
buttonTexture,
(Rectangle){0.0, buttonY, buttonWidth, buttonHeight},
"Upgrades",
WHITE,
BLACK
);
gameScreen->achievementsButton = createTexturedButton(
buttonTexture,
(Rectangle){buttonWidth, buttonY, buttonWidth, buttonHeight},
"Achievements",
WHITE,
BLACK
);
gameScreen->rebirthButton = createTexturedButton(
buttonTexture,
(Rectangle){buttonWidth * 2.0, buttonY, buttonWidth, buttonHeight},
"Rebirth",
WHITE,
BLACK
);
gameScreen->statisticsButton = createTexturedButton(
buttonTexture,
(Rectangle){buttonWidth * 3.0, buttonY, buttonWidth, buttonHeight},
"Statistics",
WHITE,
BLACK
);
}
void updateGameScreen(GameScreen* gameScreen, Game* game)
{
// Draw background.
Texture background = game->assets.textures[MAIN_SCREEN_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
);
// Navigation buttons.
updateTexturedButton(&gameScreen->toGameButton);
updateTexturedButton(&gameScreen->toEmperorsEmporiumButton);
// Button panel.
runAnimation(&gameScreen->buttonPanelSharedAnimation);
updateTexturedButton(&gameScreen->upgradesButton);
updateTexturedButton(&gameScreen->achievementsButton);
updateTexturedButton(&gameScreen->rebirthButton);
updateTexturedButton(&gameScreen->statisticsButton);
}
void closeGameScreen(GameScreen* gameScreen)
{
closeAnimation(&gameScreen->buttonPanelSharedAnimation);
}
|