diff options
| author | nathan <nathansmith@disroot.org> | 2025-12-03 11:26:25 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-12-03 11:26:25 +0000 |
| commit | ece5a7781aac05e396b246306fac5ad187fbc88a (patch) | |
| tree | c43b9bc0bfe6fc511858630c40a12e8665fb2ca8 | |
| parent | d32c6c486e99bce597b894ddb73e63737d63809f (diff) | |
| download | FindThings-ece5a7781aac05e396b246306fac5ad187fbc88a.tar.gz FindThings-ece5a7781aac05e396b246306fac5ad187fbc88a.tar.bz2 FindThings-ece5a7781aac05e396b246306fac5ad187fbc88a.zip | |
Entity thingy in map preview
| -rw-r--r-- | src/map.c | 35 | ||||
| -rw-r--r-- | src/map.h | 2 |
2 files changed, 31 insertions, 6 deletions
@@ -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); } @@ -16,7 +16,7 @@ typedef struct { RenderTexture render; RenderTexture blackout; Camera2D camera; - Texture heightmap; + Texture texture; Vector2 playerPosition; bool isEnabled; bool isFullSize; |
