diff options
| author | nathan <nathansmith@disroot.org> | 2025-11-27 11:25:35 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-11-27 11:25:35 +0000 |
| commit | 3b1165d172779c4663662e83cf5935f039fdad1b (patch) | |
| tree | 13ca328d02a5044ba433e4a832172f6700a353e5 | |
| parent | 73a98475757c34d6a8a485ac9c06185bdfdeea8c (diff) | |
| download | FindThings-3b1165d172779c4663662e83cf5935f039fdad1b.tar.gz FindThings-3b1165d172779c4663662e83cf5935f039fdad1b.tar.bz2 FindThings-3b1165d172779c4663662e83cf5935f039fdad1b.zip | |
Working on map blackout
| -rw-r--r-- | src/map.c | 23 | ||||
| -rw-r--r-- | src/map.h | 4 |
2 files changed, 26 insertions, 1 deletions
@@ -51,6 +51,7 @@ void initMap(Map* map, const World* world, const Settings* settings) settings->mapPreviewHeight}, .render = LoadRenderTexture(settings->mapPreviewWidth, settings->mapPreviewHeight), + .blackout = LoadRenderTexture(BLACKOUT_WIDTH, BLACKOUT_HEIGHT), .camera = (Camera2D){ .offset = (Vector2){settings->mapPreviewWidth / 2.0, settings->mapPreviewHeight / 2.0}, @@ -63,6 +64,11 @@ void initMap(Map* map, const World* world, const Settings* settings) .isFullSize = false }; + // Init blackout texture. + BeginTextureMode(map->blackout); + ClearBackground(BLACK); + EndTextureMode(); + initMapHeightmap(map, world, settings); repositionMap(map); } @@ -76,7 +82,7 @@ void drawMapPlayer(Map* map, Player* player, Vector2 position, (Vector2){-width, -height} }; - // Move player to position. + // Rotate and move player. for (int index = 0; index < 3; ++index) { playerPreview[index] = Vector2Rotate(playerPreview[index], @@ -90,6 +96,12 @@ void drawMapPlayer(Map* map, Player* player, Vector2 position, WHITE); } +void updateMapBlackout(Map* map, Game* game) +{ + BeginTextureMode(map->blackout); + EndTextureMode(); +} + void updateMapPreview(Map* map, Game* game) { const Settings* settings = &game->settings; @@ -124,6 +136,14 @@ void updateMapPreview(Map* map, Game* game) DrawTexture(map->heightmap, 0.0, 0.0, (Color){255, 255, 255, settings->mapAlpha}); + // Draw blackout. + DrawTexturePro(map->blackout.texture, + (Rectangle){0.0, 0.0, BLACKOUT_WIDTH, BLACKOUT_HEIGHT}, + (Rectangle){0.0, 0.0, WORLD_IMAGE_WIDTH, WORLD_IMAGE_HEIGHT}, + (Vector2){0.0, 0.0}, + 0.0, + WHITE); + EndMode2D(); EndTextureMode(); @@ -171,5 +191,6 @@ void updateMap(Map* map, Game* game) void closeMap(Map* map) { UnloadRenderTexture(map->render); + UnloadRenderTexture(map->blackout); UnloadTexture(map->heightmap); } @@ -7,9 +7,13 @@ #define MAP_ZOOM_MIN 0.5 #define MAP_ZOOM_MAX 30.0 +#define BLACKOUT_WIDTH 100 +#define BLACKOUT_HEIGHT 100 + typedef struct { Rectangle rect; RenderTexture render; + RenderTexture blackout; Camera2D camera; Texture heightmap; Vector2 playerPosition; |
