From 433f61f3c8a7cd06aaeaaac5d38cec5444f82b3f Mon Sep 17 00:00:00 2001 From: nathan Date: Sat, 20 Sep 2025 03:25:53 -0600 Subject: Samantha's spot --- src/entity.c | 2 +- src/entity.h | 6 +++--- src/player.c | 2 +- src/player.h | 1 + src/world.c | 35 +++++++++++++++++++++++++++++++---- src/world.h | 6 ++++++ 6 files changed, 43 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/entity.c b/src/entity.c index b7548be..18e44aa 100644 --- a/src/entity.c +++ b/src/entity.c @@ -66,7 +66,7 @@ Entity createEntity(EntityId id, Vector3 position) void updateEntity(Entity* entity, Game* game) { - DrawBoundingBox(entity->box, RED); + //DrawBoundingBox(entity->box, RED); switch (entity->id) { diff --git a/src/entity.h b/src/entity.h index aaf0e82..7779bca 100644 --- a/src/entity.h +++ b/src/entity.h @@ -17,9 +17,9 @@ #define UTILITY_POLE_HEIGHT 100.0 #define UTILITY_POLE_RADIUS 3.0 -#define SAMANTHA_WIDTH 23.6414/2.0 -#define SAMANTHA_HEIGHT 28.5382/2.0 -#define SAMANTHA_THICKNESS 13.0529/2.0 +#define SAMANTHA_WIDTH 3.54621/2.0 +#define SAMANTHA_HEIGHT 4.28073/2.0 +#define SAMANTHA_THICKNESS 1.95793/2.0 #define SAMANTHA_STATIC_SPEED 24 #define SAMANTHA_STATIC_FRAMES 4 diff --git a/src/player.c b/src/player.c index 64bdce6..417c7e1 100644 --- a/src/player.c +++ b/src/player.c @@ -71,7 +71,7 @@ void updatePlayer(Player* player, Game* game) player->velocity.x += -sinf(cameraAngle->x + (PI / 2.0)); } - player->velocity = Vector3Scale(player->velocity, 60.0); + player->velocity = Vector3Scale(player->velocity, PLAYER_SPEED); // Apply velocity. player->position = Vector3Add( diff --git a/src/player.h b/src/player.h index 0bd664e..9bc049f 100644 --- a/src/player.h +++ b/src/player.h @@ -4,6 +4,7 @@ #define PLAYER_H #define PLAYER_HEIGHT 2.0 +#define PLAYER_SPEED 10.0 typedef struct { Vector3 position; diff --git a/src/world.c b/src/world.c index 82ee6da..c7c34d5 100644 --- a/src/world.c +++ b/src/world.c @@ -485,10 +485,16 @@ Seed generatePond(World* world, Color* heightmap, WorldUID id, Seed seed) return seed; } -// TODO: get this mother fucker done in a sane amount of time -Seed generateWorldSamanthasPlace(World* world, Seed seed, int spotIndex) +void generateWorldSamanthasPlace(World* world, Color* heightmap) { - return seed; + 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 + }; + + averageOutAreaWorld(world, heightmap, area); } Seed generateWorldPlants(World* world, Seed seed, int start, int end) @@ -653,6 +659,18 @@ Texture generateGroundTexture() return texture; } +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; +} + World createWorld(Seed seed, const Assets* assets) { World world; @@ -668,9 +686,13 @@ World createWorld(Seed seed, const Assets* assets) // Places. WorldUID placeId = 0; + + // Pond. seed = generatePond(&world, colors, placeId, seed); world.places[0] = placeId; + generateWorldSamanthasPlace(&world, colors); + // Heightmap model. image = (Image){ .data = colors, @@ -705,9 +727,14 @@ World createWorld(Seed seed, const Assets* assets) end = WORLD_UTILITY_POLE_COUNT + start; seed = generateWorldUtilityPoles(&world, assets, seed, start, end); + // Characters. + start = end; + end = WORLD_CHARACTER_COUNT + start; + seed = generateWorldCharacters(&world, seed, start); + // Items. start = end; - end = WORLD_ENTITY_MAX - 1; + end = WORLD_ENTITY_MAX; seed = generateWorldItems(&world, seed, start, end); // Generate BVH. diff --git a/src/world.h b/src/world.h index 9e5c4c4..338f935 100644 --- a/src/world.h +++ b/src/world.h @@ -31,6 +31,12 @@ #define PLACE_POND_OUTER_AREA 25 #define PLACE_POND_WALKING_AREA 7 +// Characters. +#define WORLD_CHARACTER_COUNT 1 + +#define PLACE_SAMANTHAS_SPOT_SIZE 10 +#define SAMANTHA_OFFSET (Vector3){0.0, 0.0, 2.0} + // UID for anything in the world. typedef int16_t WorldUID; typedef int Seed; -- cgit v1.2.3