aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-12-27 18:10:11 +0000
committernathan <nathansmith@disroot.org>2025-12-27 18:10:11 +0000
commit525b9023b83014c46a4a21ec9a729b559d6be0b3 (patch)
treea6b5bb5a6ed0f374f02529c601a74f2562fd7ba8
parentfee3654661e1411232a302d951b10cbd44d3fa91 (diff)
downloadFindThings-525b9023b83014c46a4a21ec9a729b559d6be0b3.tar.gz
FindThings-525b9023b83014c46a4a21ec9a729b559d6be0b3.tar.bz2
FindThings-525b9023b83014c46a4a21ec9a729b559d6be0b3.zip
Fixed place generation a bit
-rw-r--r--src/entities/johnsStore.c31
-rw-r--r--src/world.c71
2 files changed, 69 insertions, 33 deletions
diff --git a/src/entities/johnsStore.c b/src/entities/johnsStore.c
index 8655c7d..3a96afc 100644
--- a/src/entities/johnsStore.c
+++ b/src/entities/johnsStore.c
@@ -2,20 +2,25 @@
void initJohnsStore(Entity* entity)
{
- bool cubemap[8][8] = {
- {true, true, true, true, true, true, true, true},
- {true, false, false, false, false, false, false, true},
- {true, false, false, false, false, false, false, true},
- {true, false, false, false, false, false, false, true},
- {true, false, false, false, false, false, false, true},
- {true, false, false, false, false, false, false, true},
- {true, false, false, false, false, false, false, true},
- {true, true, true, false, false, true, true, true}
- };
+ /* bool cubemap[8][8] = { */
+ /* {true, true, true, true, true, true, true, true}, */
+ /* {true, false, false, false, false, false, false, true}, */
+ /* {true, false, false, false, false, false, false, true}, */
+ /* {true, false, false, false, false, false, false, true}, */
+ /* {true, false, false, false, false, false, false, true}, */
+ /* {true, false, false, false, false, false, false, true}, */
+ /* {true, false, false, false, false, false, false, true}, */
+ /* {true, true, true, false, false, true, true, true} */
+ /* }; */
+
+ /* Image heightmap = generateCubemapImage((const bool**)cubemap, 8, 8); */
+ /* entity->data = (void*)createEntityBuilding(heightmap); */
+ /* UnloadImage(heightmap); */
- Image heightmap = generateCubemapImage((const bool**)cubemap, 8, 8);
- entity->data = (void*)createEntityBuilding(heightmap);
- UnloadImage(heightmap);
+ entity->box = (BoundingBox){
+ .min = (Vector3){-1.0, -1.0, -1.0},
+ .max = (Vector3){1.0, 1.0, 1.0}
+ };
}
void updateJohnsStore(Entity* entity, Game* game)
diff --git a/src/world.c b/src/world.c
index a6fdf24..deb3b97 100644
--- a/src/world.c
+++ b/src/world.c
@@ -412,14 +412,19 @@ void averageOutAreaWorld(const World* world, Color* heightmap, Rectangle area)
setWorldAreaToHeight(heightmap, area, height);
}
-Seed generatePond(World* world, Color* heightmap, WorldUID id, Seed seed)
+Seed generatePond(World* world, Color* heightmap, WorldUID* placeId,
+ WorldUID* id, Seed seed)
{
// Create pond entity.
Vector3 position = getRandomPositionFromCenter(world, &seed,
PLACE_POND_MIN_DISTANCE,
PLACE_POND_MAX_DISTANCE);
Entity pond = createEntity(POND, position);
- world->entities[id] = pond;
+ world->entities[*id] = pond;
+ world->places[*placeId] = *id;
+
+ *id = *id + 1;
+ *placeId = *placeId + 1;
// Get lowest height.
int height = 255;
@@ -488,7 +493,8 @@ Seed generatePond(World* world, Color* heightmap, WorldUID id, Seed seed)
}
void generateWorldSamanthasPlace(World* world, const Assets* assets,
- Color* heightmap, WorldUID* placeId)
+ Color* heightmap, WorldUID* placeId,
+ WorldUID* id)
{
// Make area flat.
float width = SAMANTHAS_SPOT_SIZE * (WORLD_IMAGE_WIDTH / world->size.x)
@@ -508,15 +514,17 @@ void generateWorldSamanthasPlace(World* world, const Assets* assets,
// Samanthas spot.
Vector3 center = Vector3Scale(world->size, 0.5);
Entity spot = createEntity(SAMANTHAS_SPOT, center);
- world->entities[*placeId] = spot;
- world->places[*placeId] = *placeId;
+ world->entities[*id] = spot;
+ world->places[*placeId] = *id;
+
+ *id = *id + 1;
*placeId = *placeId + 1;
// Samantha.
Entity samantha = createEntity(SAMANTHA, Vector3Add(center,
SAMANTHA_OFFSET));
- world->entities[*placeId] = samantha;
- *placeId = *placeId + 1;
+ world->entities[*id] = samantha;
+ *id = *id + 1;
// Trashcans yippee!
Vector3 trashPosition = (Vector3){-SAMANTHAS_SPOT,
@@ -527,8 +535,8 @@ void generateWorldSamanthasPlace(World* world, const Assets* assets,
{
Entity trashcan = createEntity(TRASHCAN,
Vector3Add(trashPosition, center));
- world->entities[*placeId] = trashcan;
- *placeId = *placeId + 1;
+ world->entities[*id] = trashcan;
+ *id = *id + 1;
trashPosition.x += (float)(SAMANTHAS_SPOT_SIZE * 2.0)
/ SAMANTHAS_SPOT_TRASHCAN_COUNT;
}
@@ -542,8 +550,8 @@ void generateWorldSamanthasPlace(World* world, const Assets* assets,
{
Entity trash = createEntity(index % 2 == 0 ? TRASH : MEDICAL_TRASH,
Vector3Add(trashPosition, center));
- world->entities[*placeId] = trash;
- *placeId = *placeId + 1;
+ world->entities[*id] = trash;
+ *id = *id + 1;
trashPosition.x += (float)(SAMANTHAS_SPOT_SIZE * 2.0)
/ SAMANTHAS_SPOT_TRASH_COUNT;
}
@@ -557,6 +565,13 @@ void generateWorldSamanthasPlace(World* world, const Assets* assets,
.texture = assets->textures[SAMANTHA_FLOOR_TEXTURE];
}
+void generateJohnsShop(World* world, Color* colors, WorldUID* placeId)
+{
+ Vector3 position = Vector3Scale(world->size, 0.5);
+ Entity johnsShop = createEntity(JOHNS_STORE, position);
+ world->entities[*placeId] = johnsShop;
+}
+
Seed generateWorldPlants(World* world, Seed seed, int start, int end)
{
for (int index = start; index < end; ++index)
@@ -730,6 +745,27 @@ Seed generateWorldCharacters(World* world, Seed seed, WorldUID start)
return seed;
}
+Seed generateWorldPlaces(World* world, const Assets* assets, Color* colors,
+ Seed seed, WorldUID* id)
+{
+ WorldUID placeId = 0;
+
+ // Pond.
+ seed = generatePond(world, colors, &placeId, id, seed);
+
+ // Samantha's place.
+ generateWorldSamanthasPlace(world, assets, colors, &placeId, id);
+
+ // Sanity check (something I should do more often...)
+ if (placeId != WORLD_PLACE_COUNT)
+ {
+ TraceLog(LOG_WARNING, "placeId is %d when it should be %d", placeId,
+ WORLD_PLACE_COUNT);
+ }
+
+ return seed;
+}
+
World createWorld(Seed seed, const Assets* assets)
{
World world;
@@ -744,14 +780,9 @@ World createWorld(Seed seed, const Assets* assets)
UnloadImage(image);
// Places.
- WorldUID placeId = 0;
-
- // Pond.
- seed = generatePond(&world, colors, placeId, seed);
- world.places[0] = placeId;
+ WorldUID id = 0;
- ++placeId;
- generateWorldSamanthasPlace(&world, assets, colors, &placeId);
+ seed = generateWorldPlaces(&world, assets, colors, seed, &id);
// Heightmap model.
image = (Image){
@@ -768,7 +799,7 @@ World createWorld(Seed seed, const Assets* assets)
UnloadImage(image);
// Put places on ground.
- for (int index = 0; index < placeId; ++index)
+ for (int index = 0; index < id; ++index)
{
placeEntityOnGround(&world.entities[index], &world);
}
@@ -778,7 +809,7 @@ World createWorld(Seed seed, const Assets* assets)
generateGroundTexture();
// Plants
- int start = placeId + 1;
+ int start = id;
int end = WORLD_PLANT_COUNT + start;
seed = generateWorldPlants(&world, seed, start, end);