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
|
#include "gameScreen.h"
#include "game.h"
#include "world.h"
#include "bullets.h"
#include <raylib.h>
void drawCrossHair(float size, float thick, Color color) {
Vector3 center = (Vector3){GetScreenWidth() / 2.0, GetScreenHeight() / 2.0};
// Left to right.
DrawLineEx(
(Vector2){center.x - size, center.y},
(Vector2){center.x + size, center.y},
thick,
color
);
// Top to bottom.
DrawLineEx(
(Vector2){center.x, center.y - size},
(Vector2){center.x, center.y + size},
thick,
color
);
}
void updateGameScreen(Game * game) {
ClearBackground(BLACK);
// Draw cross hair.
drawCrossHair(10.0, 2.0, BLUE);
// Update world.
updateWorld(&game->world, game);
// Camera.
updatePlayerCamera(&game->playerCamera, game);
// Draw.
BeginMode3D(game->playerCamera);
DrawGrid(50, 25.0);
// Draw world.
drawWorld(&game->world, game);
EndMode3D();
}
void openGameScreen(Game * game) {
game->screenId = SCREEN_GAME;
if (game->settings.lockMouse)
DisableCursor();
}
void closeGameScreen(Game * game) {
if (game->settings.lockMouse)
EnableCursor();
}
|