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
|
#include "game.h"
void initGame(Game* game)
{
InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Penguin Yippies!");
SetWindowState(FLAG_WINDOW_RESIZABLE);
// Assets.
initAssets(&game->assets);
// Screens.
game->currentScreen = MAIN_MENU_SCREEN;
initMainMenu(&game->mainMenu, game);
initGameScreen(&game->gameScreen, game);
game->screenTexture = LoadRenderTexture(WINDOW_WIDTH, WINDOW_HEIGHT);
}
void updateGame(Game* game)
{
// Draw screen.
BeginTextureMode(game->screenTexture);
switch (game->currentScreen)
{
case MAIN_MENU_SCREEN:
updateMainMenu(&game->mainMenu, game);
break;
case GAME_SCREEN:
updateGameScreen(&game->gameScreen, game);
break;
default:
break;
}
EndTextureMode();
// Draw the silly silly render texture.
BeginDrawing();
DrawTexturePro(
game->screenTexture.texture,
(Rectangle){0.0, 0.0, game->screenTexture.texture.width, -game->screenTexture.texture.height},
(Rectangle){0.0, 0.0, GetScreenWidth(), GetScreenHeight()},
Vector2Zero(),
0.0,
WHITE
);
EndDrawing();
}
void closeGame(Game* game)
{
closeAssets(&game->assets);
closeMainMenu(&game->mainMenu);
closeGameScreen(&game->gameScreen);
UnloadRenderTexture(game->screenTexture);
CloseWindow();
}
|