Refactor crosshair

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)
-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
diff --git a/Makefile b/Makefile
...
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
...
diff --git a/all.h b/all.h
...
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
  
...
diff --git a/game.c b/game.c
...
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
  
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
}