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
|
#include "game.h"
#include "utils.h"
void initGame(Game* game)
{
game->sceneId = GAME_SCENE;
// Settings.
game->settings = defaultSettings();
// Window.
InitWindow(game->settings.windowWidth, game->settings.windowHeight,
"Find Things");
SetWindowState(FLAG_WINDOW_RESIZABLE);
// Assets.
initAssets(&game->assets);
// Player.
game->player = createPlayer();
game->player.position = (Vector3){50.0, 30.0, 50.0};
// World.
game->world = createWorld(&game->assets);
game->entities[0] = createEntity(OLD_MINT, (Vector3){100.0, 0.0, 100.0});
game->entities[1] = createEntity(STICKY_NICKEL,
(Vector3){100.0, 0.0, 105.0});
game->entities[0].position.y = getWorldHeightAtLocation(game->world,
100, 100) + 1.0;
game->entities[1].position.y = getWorldHeightAtLocation(game->world,
100, 105) + 1.0;
DisableCursor();
}
void updateMainMenuScene(Game* game)
{
ClearBackground(BLACK);
}
void updateGameScene(Game* game)
{
ClearBackground(BLACK);
BeginMode3D(game->player.camera);
updatePlayer(&game->player, game);
updateWorld(&game->world, game);
for (int index = 0; index < 2; ++index)
{
updateEntity(&game->entities[index], game);
}
EndMode3D();
}
void updateGame(Game* game)
{
BeginDrawing();
switch (game->sceneId)
{
case MAIN_MENU_SCENE:
updateMainMenuScene(game);
break;
case GAME_SCENE:
updateGameScene(game);
break;
default:
break;
}
DrawFPS(0, 0);
EndDrawing();
}
void closeGame(Game* game)
{
closeAssets(&game->assets);
freeWorld(game->world);
CloseWindow();
}
|