From ece5a7781aac05e396b246306fac5ad187fbc88a Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 3 Dec 2025 04:26:25 -0700 Subject: Entity thingy in map preview --- src/map.c | 35 ++++++++++++++++++++++++++++++----- src/map.h | 2 +- 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/map.c b/src/map.c index d0fc4ed..58b3021 100644 --- a/src/map.c +++ b/src/map.c @@ -2,18 +2,36 @@ #include "game.h" #include "world.h" #include "player.h" +#include "entity.h" void repositionMap(Map* map) { map->rect.x = GetRenderWidth() - map->rect.width; } -void initMapHeightmap(Map* map, const World* world, const Settings* settings) +void renderMapEntityPreview(Image* map, Entity entity, const World* world) +{ + Vector2 position = (Vector2){ + WORLD_IMAGE_WIDTH / world->size.x * entity.position.x, + WORLD_IMAGE_HEIGHT / world->size.z * entity.position.z + }; + + switch (entity.id) + { + case POND: + break; + default: + break; + } +} + +void initMapTexture(Map* map, const World* world, const Settings* settings) { Image image = LoadImageFromTexture(world->heightmapTexture); Color* colors = LoadImageColors(image); UnloadImage(image); + // Color filter the texture. for (int index = 0; index < WORLD_IMAGE_WIDTH * WORLD_IMAGE_HEIGHT; ++index) { float height = (float)GRAY_VALUE(colors[index]) / 255.0; @@ -39,8 +57,14 @@ void initMapHeightmap(Map* map, const World* world, const Settings* settings) .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, .mipmaps = 1 }; + + // Draw entities. + for (int index = 0; index < WORLD_ENTITY_MAX; ++index) + { + renderMapEntityPreview(&image, world->entities[index], world); + } - map->heightmap = LoadTextureFromImage(image); + map->texture = LoadTextureFromImage(image); UnloadImage(image); } @@ -69,7 +93,7 @@ void initMap(Map* map, const World* world, const Settings* settings) ClearBackground(BLACK); EndTextureMode(); - initMapHeightmap(map, world, settings); + initMapTexture(map, world, settings); repositionMap(map); } @@ -154,7 +178,8 @@ void updateMapPreview(Map* map, Game* game) ClearBackground(BLANK); // Draw height map. - DrawTexture(map->heightmap, 0.0, 0.0, WHITE); + DrawTexture(map->texture, 0.0, 0.0, WHITE); + // Draw blackout. DrawTexturePro(map->blackout.texture, @@ -212,5 +237,5 @@ void closeMap(Map* map) { UnloadRenderTexture(map->render); UnloadRenderTexture(map->blackout); - UnloadTexture(map->heightmap); + UnloadTexture(map->texture); } diff --git a/src/map.h b/src/map.h index ab0b541..052762c 100644 --- a/src/map.h +++ b/src/map.h @@ -16,7 +16,7 @@ typedef struct { RenderTexture render; RenderTexture blackout; Camera2D camera; - Texture heightmap; + Texture texture; Vector2 playerPosition; bool isEnabled; bool isFullSize; -- cgit v1.2.3