diff options
Diffstat (limited to 'src/game.c')
| -rw-r--r-- | src/game.c | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -112,7 +112,7 @@ void initGame(Game* game) 100.0, 100.0}); addWindowToWindowManager(&game->wm, window); - window = createFloatingWindow("test2", + window = createFloatingWindow("test2",\ (Rectangle){200.0, 200.0, 100.0, 100.0}); window.callback = testFloatingWindowCallback; addWindowToWindowManager(&game->wm, window); @@ -170,6 +170,29 @@ void drawGameScreen(Game* game) } } +void drawCrosshair(float crossHairSize, float crossHairThickness, Color color) +{ + float screenHalfWidth = GetRenderWidth() / 2.0; + float screenHalfHeight = GetRenderHeight() / 2.0; + float halfThickness = crossHairThickness / 2.0; + + // Vertical. + DrawLineEx( + (Vector2){screenHalfWidth - crossHairSize, + screenHalfHeight}, + (Vector2){screenHalfWidth + crossHairSize, + screenHalfHeight}, + crossHairThickness, color); + + // Horizontal. + DrawLineEx( + (Vector2){screenHalfWidth, + screenHalfHeight - crossHairSize}, + (Vector2){screenHalfWidth, + screenHalfHeight + crossHairSize}, + crossHairThickness, color); +} + void updateGameScene(Game* game) { // Handle toggle cursor. @@ -207,6 +230,13 @@ void updateGameScene(Game* game) drawGameScreen(game); updateWindowManager(&game->wm, game); + + if (!game->isCursorEnabled) + { + drawCrosshair(game->settings.crossHairSize, + game->settings.crossHairThickness, + game->settings.crossHairColor); + } } void handleGameResize(Game* game) |
