diff options
author | nathan <nathansmith@disroot.org> | 2025-07-29 03:07:22 +0000 |
---|---|---|
committer | nathan <nathansmith@disroot.org> | 2025-07-29 03:07:22 +0000 |
commit | 6bcf165f3af3da713953b9b3b80b4f101f7a0f7a (patch) | |
tree | 7b85781c886cd18f10f119944c59e51310ca0d51 | |
parent | 2aae6dcb8e4ab7261f4449e99b7724e665db3e3b (diff) | |
download | FindThings-6bcf165f3af3da713953b9b3b80b4f101f7a0f7a.tar.gz FindThings-6bcf165f3af3da713953b9b3b80b4f101f7a0f7a.tar.bz2 FindThings-6bcf165f3af3da713953b9b3b80b4f101f7a0f7a.zip |
Lazy
-rw-r--r-- | src/game.c | 8 | ||||
-rw-r--r-- | src/world.c | 19 | ||||
-rw-r--r-- | src/world.h | 7 |
3 files changed, 21 insertions, 13 deletions
@@ -29,13 +29,13 @@ void initGame(Game* game) LoadTextureCubemap(game->assets.images[SKYBOX_IMAGE], CUBEMAP_LAYOUT_AUTO_DETECT); - // Player. - game->player = createPlayer(); - game->player.position = (Vector3){0.0, 30.0, 0.0}; - // World. game->world = createWorld(134235234); + // Player. + game->player = createPlayer(); + game->player.position = Vector3Scale(game->world.size, 0.5); + DisableCursor(); } diff --git a/src/world.c b/src/world.c index c2159d8..fd6fc19 100644 --- a/src/world.c +++ b/src/world.c @@ -328,9 +328,9 @@ void buildWorldBVH(World* world) world->bvhDebugSelect = 0; } -Seed generateWorldPlants(World* world, Seed seed) +Seed generateWorldPlants(World* world, Seed seed, int start, int end) { - for (int index = 0; index < WORLD_PLANT_COUNT; ++index) + for (int index = start; index < end; ++index) { FT_RANDOM16(seed); @@ -355,9 +355,9 @@ Seed generateWorldPlants(World* world, Seed seed) return seed; } -Seed generateWorldItems(World* world, Seed seed) +Seed generateWorldItems(World* world, Seed seed, int start, int end) { - for (int index = WORLD_PLANT_COUNT; index < WORLD_ENTITY_MAX; ++index) + for (int index = start; index < end; ++index) { FT_RANDOM16(seed); @@ -381,7 +381,12 @@ Seed generateWorldItems(World* world, Seed seed) Seed generatePond(World* world, Seed seed) { - Vector3 position; + // Get position. + int distanceRange = PLACE_POND_MAX_DISTANCE * 2; + Vector3 position = Vector3Scale(world->size, 0.5); + position.x += FT_RANDOM16(seed) % distanceRange - PLACE_POND_MAX_DISTANCE; + position.z += FT_RANDOM16(seed) % distanceRange - PLACE_POND_MAX_DISTANCE; + return seed; } @@ -415,8 +420,8 @@ World createWorld(Seed seed) // Places. generatePond(&world, seed); - seed = generateWorldPlants(&world, seed); - seed = generateWorldItems(&world, seed); + seed = generateWorldPlants(&world, seed, 0, WORLD_PLANT_COUNT); + seed = generateWorldItems(&world, seed, WORLD_PLANT_COUNT, WORLD_ENTITY_MAX); // Generate BVH. double currentTime = GetTime(); diff --git a/src/world.h b/src/world.h index 3b1ca4d..2097c94 100644 --- a/src/world.h +++ b/src/world.h @@ -5,8 +5,8 @@ #ifndef WORLD_H #define WORLD_H -#define WORLD_ENTITY_MAX 1500 -#define WORLD_PLANT_COUNT 500 +#define WORLD_ENTITY_MAX 3000 +#define WORLD_PLANT_COUNT 1000 #define WORLD_PLACE_COUNT 1 #define WORLD_SIZE (Vector3){4096.0, 256.0, 4096.0} @@ -23,6 +23,9 @@ #define BVH_MAX_BRANCH_COUNT 8 #define BVH_BOX_MAX 100.0 +// Places. +#define PLACE_POND_MAX_DISTANCE 100 // Max distance from center. + // UID for anything in the world. typedef int16_t WorldUID; typedef int Seed; |