diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-04-30 19:07:38 +0200 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-04-30 19:07:38 +0200 |
| commit | 16adefc98106a7f401a00864122f65f64305ecce (patch) | |
| tree | 53f2e729eab38e34cb2efdb9216dd90130fa39b6 | |
| parent | 6307feb53d978cbf7f50df26a7b0bc63252cfbd4 (diff) | |
| download | stalag-16adefc98106a7f401a00864122f65f64305ecce.tar.gz | |
Refactor crosshair
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | all.h | 3 | ||||
| -rw-r--r-- | game.c | 5 | ||||
| -rw-r--r-- | interface.c | 8 |
4 files changed, 13 insertions, 5 deletions
| @@ -16,7 +16,7 @@ LDFLAGS := ./vendor/$(RAYLIB_VER)/lib/libraylib.a -lm | |||
| 16 | GAME := bin/stalag | 16 | GAME := bin/stalag |
| 17 | HEXDUMP := bin/hexdump | 17 | HEXDUMP := bin/hexdump |
| 18 | PACKER := bin/packer | 18 | PACKER := bin/packer |
| 19 | SOURCES := main.c map.c game.c player.c | 19 | SOURCES := main.c map.c game.c player.c interface.c |
| 20 | 20 | ||
| 21 | ifeq ($(SYSTEM), linux_amd64) | 21 | ifeq ($(SYSTEM), linux_amd64) |
| 22 | LDFLAGS += -lX11 | 22 | LDFLAGS += -lX11 |
| @@ -138,6 +138,9 @@ void DrawGame(void); | |||
| 138 | bool LoadMap(const char *filename); | 138 | bool LoadMap(const char *filename); |
| 139 | void UnloadMap(void); | 139 | void UnloadMap(void); |
| 140 | 140 | ||
| 141 | // Interface | ||
| 142 | void DrawCrosshair(void); | ||
| 143 | |||
| 141 | // Player | 144 | // Player |
| 142 | void UpdatePlayer(void); | 145 | void UpdatePlayer(void); |
| 143 | 146 | ||
| @@ -324,10 +324,7 @@ void DrawGame(void) { | |||
| 324 | 324 | ||
| 325 | EndMode3D(); | 325 | EndMode3D(); |
| 326 | 326 | ||
| 327 | int screenWidth = GetScreenWidth(); | 327 | DrawCrosshair(); |
| 328 | int screenHeight = GetScreenHeight(); | ||
| 329 | DrawLine(screenWidth / 2 - 10, screenHeight / 2, screenWidth / 2 + 10, screenHeight / 2, GREEN); | ||
| 330 | DrawLine(screenWidth / 2, screenHeight / 2 - 10, screenWidth / 2, screenHeight / 2 + 10, GREEN); | ||
| 331 | 328 | ||
| 332 | DrawTextEx(game.font_ui, TextFormat("%i FPS", GetFPS()), (Vector2){ 10, 10 }, 20, 2, GREEN); | 329 | DrawTextEx(game.font_ui, TextFormat("%i FPS", GetFPS()), (Vector2){ 10, 10 }, 20, 2, GREEN); |
| 333 | DrawTextEx(game.font_ui, TextFormat("VSync: %s", game.vsync ? "ON" : "OFF"), (Vector2){ 10, 35 }, 20, 2, GREEN); | 330 | DrawTextEx(game.font_ui, TextFormat("VSync: %s", game.vsync ? "ON" : "OFF"), (Vector2){ 10, 35 }, 20, 2, GREEN); |
diff --git a/interface.c b/interface.c new file mode 100644 index 0000000..a376ed2 --- /dev/null +++ b/interface.c | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #include "all.h" | ||
| 2 | |||
| 3 | void DrawCrosshair(void) { | ||
| 4 | int screenWidth = GetScreenWidth(); | ||
| 5 | int screenHeight = GetScreenHeight(); | ||
| 6 | DrawLine(screenWidth / 2 - 10, screenHeight / 2, screenWidth / 2 + 10, screenHeight / 2, GREEN); | ||
| 7 | DrawLine(screenWidth / 2, screenHeight / 2 - 10, screenWidth / 2, screenHeight / 2 + 10, GREEN); | ||
| 8 | } | ||
