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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
#include "gameScreen.h"
#include "game.h"
#include "assets.h"
#include "util.h"
#include <raylib.h>
void initGameScreen(GameScreen* gameScreen, Game* game)
{
gameScreen->place = CLICKY_DESKTOP_PLACE;
Assets* assets = &game->assets;
int width = WINDOW_WIDTH;
int height = WINDOW_HEIGHT;
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
);
initShop(&gameScreen->shop, game);
setGameScreenTool(gameScreen, CLICKER_TOOL);
}
void updateGameScreenClickyDesktop(GameScreen* gameScreen, Game* game)
{
// Clickies clickies.
updateClickies(game, &game->clickies);
}
void updateGameScreenNavigation(GameScreen* gameScreen, Game* game)
{
// Navigation buttons.
if (updateTexturedButton(&gameScreen->toGameButton))
{
gameScreen->place = CLICKY_DESKTOP_PLACE;
}
if (updateTexturedButton(&gameScreen->toEmperorsEmporiumButton))
{
gameScreen->place = SHOP_PLACE;
}
}
void setGameScreenTool(GameScreen* gameScreen, ToolId tool)
{
gameScreen->tool = tool;
// TODO: Switch cursor for different tools
switch (tool)
{
case CLICKER_TOOL:
break;
case BOOPER_TOOL:
break;
default:
break;
}
}
void updateGameScreenToolBar(GameScreen* gameScreen, Game* game)
{
int toolIconWidth = 50;
int toolIconHeight = 50;
Assets* assets = &game->assets;
Texture toolTextures[TOOL_COUNT] = {
assets->textures[CLICKER_TOOL_TEXTURE],
assets->textures[BOOPER_TOOL_TEXTURE]
};
for (int i = 0; i < TOOL_COUNT; ++i)
{
Rectangle rect = (Rectangle){i * toolIconWidth + 200, 0.0, toolIconWidth, toolIconHeight};
Texture texture = toolTextures[i];
// Draw tool texture.
DrawTexturePro(
texture,
(Rectangle){0.0, 0.0, texture.width, texture.height},
rect,
(Vector2){0.0, 0.0},
0.0,
WHITE
);
// Outline current tool
if (i == gameScreen->tool)
{
DrawRectangleLinesEx(rect, 3, BLACK);
}
else // Switch tools.
{
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointRec(getScaledMousePosition(), rect))
{
setGameScreenTool(gameScreen, i);
}
}
}
}
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, WINDOW_WIDTH, WINDOW_HEIGHT},
(Vector2){0.0, 0.0},
0.0,
WHITE
);
// assssssss hehehe
switch (gameScreen->place)
{
case CLICKY_DESKTOP_PLACE:
updateGameScreenClickyDesktop(gameScreen, game);
break;
case SHOP_PLACE:
updateShop(&gameScreen->shop, game);
break;
default:
break;
}
// Stones.
Texture stoneTexture = game->assets.textures[STONE_TEXTURE];
DrawTexturePro(
stoneTexture,
(Rectangle){5.0, 5.0, stoneTexture.width, stoneTexture.height},
(Rectangle){0.0, 0.0, 35.0, 35.0},
(Vector2){0.0, 0.0},
0.0,
WHITE
);
char stonesBuf[30];
snprintf(stonesBuf, sizeof(stonesBuf), "%d", game->stones);
DrawText(stonesBuf, 40.0, 5.0, 30, BLACK);
updateGameScreenNavigation(gameScreen, game);
updateGameScreenToolBar(gameScreen, game);
}
void closeGameScreen(GameScreen* gameScreen)
{
closeShop(&gameScreen->shop);
}
|