From 3b1165d172779c4663662e83cf5935f039fdad1b Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 27 Nov 2025 04:25:35 -0700 Subject: Working on map blackout --- src/map.c | 23 ++++++++++++++++++++++- src/map.h | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/map.c b/src/map.c index 0ff87ea..35fa2fd 100644 --- a/src/map.c +++ b/src/map.c @@ -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); } diff --git a/src/map.h b/src/map.h index bd581ba..bb79355 100644 --- a/src/map.h +++ b/src/map.h @@ -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; -- cgit v1.2.3