diff options
| author | nathan <nathansmith@disroot.org> | 2025-11-28 06:23:42 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-11-28 06:23:42 +0000 |
| commit | d32c6c486e99bce597b894ddb73e63737d63809f (patch) | |
| tree | c315d133c56d396bc96532535c2a130405644460 /src/map.c | |
| parent | 3b1165d172779c4663662e83cf5935f039fdad1b (diff) | |
| download | FindThings-d32c6c486e99bce597b894ddb73e63737d63809f.tar.gz FindThings-d32c6c486e99bce597b894ddb73e63737d63809f.tar.bz2 FindThings-d32c6c486e99bce597b894ddb73e63737d63809f.zip | |
Map blackout working
Diffstat (limited to 'src/map.c')
| -rw-r--r-- | src/map.c | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -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), |
