diff options
Diffstat (limited to 'src/map.c')
| -rw-r--r-- | src/map.c | 23 |
1 files changed, 22 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); } |
