diff options
| author | nathan <nathansmith@disroot.org> | 2025-12-29 12:42:08 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-12-29 12:42:08 +0000 |
| commit | 91b1c45da05c892a04b6a1daa99b1de89fa1f363 (patch) | |
| tree | 5eeb0e8f7c5a4f0382b69780a4a14f69f971d9a2 /src/entity.c | |
| parent | 8f2d85aa019f089b6946f3b9e0355ce59b12b67a (diff) | |
| download | FindThings-91b1c45da05c892a04b6a1daa99b1de89fa1f363.tar.gz FindThings-91b1c45da05c892a04b6a1daa99b1de89fa1f363.tar.bz2 FindThings-91b1c45da05c892a04b6a1daa99b1de89fa1f363.zip | |
working on building roofs
Diffstat (limited to 'src/entity.c')
| -rw-r--r-- | src/entity.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/entity.c b/src/entity.c index fa3a414..1d10e4f 100644 --- a/src/entity.c +++ b/src/entity.c @@ -239,7 +239,7 @@ void placeEntityOnGround(Entity* entity, const World* world) if (entityIsBuilding(entity->id)) { - position.y += ENTITY_BUILDING_GROUND_OFFSET; + position.y += TOUCHING_OFFSET; } else { @@ -335,10 +335,22 @@ EntityBuilding* createEntityBuilding(Image heightmap) return NULL; } + float widthInWorld = heightmap.width * ENTITY_BUILDING_CUBE_SIZE.x; + float heightInWorld = heightmap.height * ENTITY_BUILDING_CUBE_SIZE.z; + *entityBuilding = (EntityBuilding){ .model = LoadModelFromMesh(GenMeshCubicmap(heightmap, ENTITY_BUILDING_CUBE_SIZE)), - .pixelMap = LoadImageColors(heightmap) + .pixelMap = LoadImageColors(heightmap), + .width = heightmap.width, + .height = heightmap.height, + .roofSize = (hypotf(widthInWorld, heightInWorld) + + ENTITY_BUILDING_CUBE_SIZE.x) / 2.0, + .roofHeight = BUILDING_DEFAULT_ROOF_HEIGHT, + .roofOffset = (Vector3){ + widthInWorld / 2.0 - ENTITY_BUILDING_CUBE_SIZE.x / 2.0, + ENTITY_BUILDING_CUBE_SIZE.y + TOUCHING_OFFSET, + heightInWorld / 2.0 - ENTITY_BUILDING_CUBE_SIZE.z / 2.0} }; return entityBuilding; @@ -353,3 +365,11 @@ void freeEntityBuilding(EntityBuilding* entityBuilding) FT_FREE(entityBuilding); } } + +void drawBuildingRoof(const EntityBuilding* building, Vector3 position, + Color color) +{ + DrawCylinder(Vector3Add(position, building->roofOffset), 1.0, + building->roofSize, building->roofHeight, BUILDING_ROOF_SLICES, + color); +} |
