aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-12-03 11:26:25 +0000
committernathan <nathansmith@disroot.org>2025-12-03 11:26:25 +0000
commitece5a7781aac05e396b246306fac5ad187fbc88a (patch)
treec43b9bc0bfe6fc511858630c40a12e8665fb2ca8
parentd32c6c486e99bce597b894ddb73e63737d63809f (diff)
downloadFindThings-ece5a7781aac05e396b246306fac5ad187fbc88a.tar.gz
FindThings-ece5a7781aac05e396b246306fac5ad187fbc88a.tar.bz2
FindThings-ece5a7781aac05e396b246306fac5ad187fbc88a.zip
Entity thingy in map preview
-rw-r--r--src/map.c35
-rw-r--r--src/map.h2
2 files changed, 31 insertions, 6 deletions
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;