From d32c6c486e99bce597b894ddb73e63737d63809f Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 27 Nov 2025 23:23:42 -0700 Subject: Map blackout working --- src/map.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'src/map.c') diff --git a/src/map.c b/src/map.c index 35fa2fd..d0fc4ed 100644 --- a/src/map.c +++ b/src/map.c @@ -98,7 +98,21 @@ void drawMapPlayer(Map* map, Player* player, Vector2 position, void updateMapBlackout(Map* map, Game* game) { + float x = (float)BLACKOUT_WIDTH / WORLD_IMAGE_WIDTH + * map->playerPosition.x; + float y = (float)BLACKOUT_HEIGHT / WORLD_IMAGE_HEIGHT + * map->playerPosition.y; + + x -= (float)BLACKOUT_AREA / 2.0; + y -= (float)BLACKOUT_AREA / 2.0; + + // Clear the part of the screen the player is on. BeginTextureMode(map->blackout); + BeginScissorMode(x, y, BLACKOUT_AREA, BLACKOUT_AREA); + + ClearBackground(BLANK); + + EndScissorMode(); EndTextureMode(); } @@ -124,21 +138,27 @@ void updateMapPreview(Map* map, Game* game) map->camera.zoom = Clamp(map->camera.zoom, MAP_ZOOM_MIN, MAP_ZOOM_MAX); } + if (IsKeyPressed(settings->defaultMapZoomKey)) + { + map->camera.zoom = settings->mapPreviewZoomDefault; + } + // Camera follow player. map->camera.target = map->playerPosition; + updateMapBlackout(map, game); + // Draw map scene. BeginTextureMode(map->render); BeginMode2D(map->camera); ClearBackground(BLANK); // Draw height map. - DrawTexture(map->heightmap, 0.0, 0.0, - (Color){255, 255, 255, settings->mapAlpha}); + DrawTexture(map->heightmap, 0.0, 0.0, WHITE); // Draw blackout. DrawTexturePro(map->blackout.texture, - (Rectangle){0.0, 0.0, BLACKOUT_WIDTH, BLACKOUT_HEIGHT}, + (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, @@ -154,7 +174,7 @@ void updateMapPreview(Map* map, Game* game) map->rect, (Vector2){0.0, 0.0}, 0.0, - WHITE); + (Color){255, 255, 255, settings->mapAlpha}); // Draw player. Vector2 mapCenter = (Vector2){map->rect.x + (map->rect.width / 2.0), -- cgit v1.2.3