aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/world.c b/src/world.c
index c7c34d5..a32bec2 100644
--- a/src/world.c
+++ b/src/world.c
@@ -485,16 +485,33 @@ Seed generatePond(World* world, Color* heightmap, WorldUID id, Seed seed)
return seed;
}
-void generateWorldSamanthasPlace(World* world, Color* heightmap)
+void generateWorldSamanthasPlace(World* world, Color* heightmap,
+ WorldUID* placeId)
{
+ // Make area flat.
+ float width = WORLD_IMAGE_WIDTH / world->size.x * SAMANTHAS_SPOT_SIZE;
+ float height = WORLD_IMAGE_HEIGHT / world->size.z * SAMANTHAS_SPOT_SIZE;
+
Rectangle area = (Rectangle){
- .x = WORLD_IMAGE_WIDTH / 2.0 - PLACE_SAMANTHAS_SPOT_SIZE / 2.0,
- .y = WORLD_IMAGE_HEIGHT / 2.0 - PLACE_SAMANTHAS_SPOT_SIZE / 2.0,
- .width = PLACE_SAMANTHAS_SPOT_SIZE,
- .height = PLACE_SAMANTHAS_SPOT_SIZE
+ .x = WORLD_IMAGE_WIDTH / 2.0 - width,
+ .y = WORLD_IMAGE_HEIGHT / 2.0 - height,
+ .width = width,
+ .height = height
};
averageOutAreaWorld(world, heightmap, area);
+
+ // Samanthas spot.
+ Vector3 center = Vector3Scale(world->size, 0.5);
+ Entity spot = createEntity(SAMANTHAS_SPOT, center);
+ world->entities[*placeId] = spot;
+ *placeId = *placeId + 1;
+
+ // Samantha.
+ Entity samantha = createEntity(SAMANTHA, Vector3Add(center,
+ SAMANTHA_OFFSET));
+ world->entities[*placeId] = samantha;
+ *placeId = *placeId + 1;
}
Seed generateWorldPlants(World* world, Seed seed, int start, int end)
@@ -661,13 +678,6 @@ Texture generateGroundTexture()
Seed generateWorldCharacters(World* world, Seed seed, int index)
{
- // Create samantha.
- Entity samantha = createEntity(
- SAMANTHA,
- Vector3Add(Vector3Scale(world->size, 0.5), SAMANTHA_OFFSET));
- placeEntityOnGround(&samantha, world);
- world->entities[index] = samantha;
-
return seed;
}
@@ -691,7 +701,8 @@ World createWorld(Seed seed, const Assets* assets)
seed = generatePond(&world, colors, placeId, seed);
world.places[0] = placeId;
- generateWorldSamanthasPlace(&world, colors);
+ ++placeId;
+ generateWorldSamanthasPlace(&world, colors, &placeId);
// Heightmap model.
image = (Image){
@@ -708,7 +719,7 @@ World createWorld(Seed seed, const Assets* assets)
UnloadImage(image);
// Put places on ground.
- for (int index = 0; index < WORLD_PLACE_COUNT; ++index)
+ for (int index = 0; index < placeId; ++index)
{
placeEntityOnGround(&world.entities[index], &world);
}
@@ -728,9 +739,9 @@ World createWorld(Seed seed, const Assets* assets)
seed = generateWorldUtilityPoles(&world, assets, seed, start, end);
// Characters.
- start = end;
- end = WORLD_CHARACTER_COUNT + start;
- seed = generateWorldCharacters(&world, seed, start);
+ /* start = end; */
+ /* end = WORLD_CHARACTER_COUNT + start; */
+ /* seed = generateWorldCharacters(&world, seed, start); */
// Items.
start = end;