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 | |
| parent | 3b1165d172779c4663662e83cf5935f039fdad1b (diff) | |
| download | FindThings-d32c6c486e99bce597b894ddb73e63737d63809f.tar.gz FindThings-d32c6c486e99bce597b894ddb73e63737d63809f.tar.bz2 FindThings-d32c6c486e99bce597b894ddb73e63737d63809f.zip | |
Map blackout working
| -rw-r--r-- | src/map.c | 28 | ||||
| -rw-r--r-- | src/map.h | 1 | ||||
| -rw-r--r-- | src/settings.c | 1 | ||||
| -rw-r--r-- | src/settings.h | 1 |
4 files changed, 27 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), @@ -9,6 +9,7 @@ #define BLACKOUT_WIDTH 100 #define BLACKOUT_HEIGHT 100 +#define BLACKOUT_AREA 18.0 typedef struct { Rectangle rect; diff --git a/src/settings.c b/src/settings.c index 0d65432..96c0fe8 100644 --- a/src/settings.c +++ b/src/settings.c @@ -35,6 +35,7 @@ Settings defaultSettings() .toggleCursorKey = KEY_LEFT_ALT, .toggleCrossHairKey = KEY_C, .toggleMapPreviewKey = KEY_P, + .defaultMapZoomKey = KEY_Z, .interactKey = KEY_E }; } diff --git a/src/settings.h b/src/settings.h index d6416ba..6418c2e 100644 --- a/src/settings.h +++ b/src/settings.h @@ -53,6 +53,7 @@ typedef struct { KeyboardKey toggleCursorKey; KeyboardKey toggleCrossHairKey; KeyboardKey toggleMapPreviewKey; + KeyboardKey defaultMapZoomKey; KeyboardKey interactKey; } Settings; |
