diff options
| author | nathan <nathansmith@disroot.org> | 2025-12-27 23:00:54 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-12-27 23:00:54 +0000 |
| commit | 8f2d85aa019f089b6946f3b9e0355ce59b12b67a (patch) | |
| tree | ac26c36f4c41f21641cf2786d740567413cd6ac5 | |
| parent | c6096a028d57da1026aa86ac215ea2f07461cd96 (diff) | |
| download | FindThings-8f2d85aa019f089b6946f3b9e0355ce59b12b67a.tar.gz FindThings-8f2d85aa019f089b6946f3b9e0355ce59b12b67a.tar.bz2 FindThings-8f2d85aa019f089b6946f3b9e0355ce59b12b67a.zip | |
Buildings going well
| -rw-r--r-- | assets/images/JohnsShop.png | bin | 0 -> 22361 bytes | |||
| -rw-r--r-- | src/assets.c | 1 | ||||
| -rw-r--r-- | src/assets.h | 3 | ||||
| -rw-r--r-- | src/entities/johnsStore.c | 21 | ||||
| -rw-r--r-- | src/entities/johnsStore.h | 1 | ||||
| -rw-r--r-- | src/entity.c | 15 | ||||
| -rw-r--r-- | src/entity.h | 3 | ||||
| -rw-r--r-- | src/utils.c | 11 | ||||
| -rw-r--r-- | src/utils.h | 2 | ||||
| -rw-r--r-- | src/world.c | 35 | ||||
| -rw-r--r-- | src/world.h | 2 |
11 files changed, 71 insertions, 23 deletions
diff --git a/assets/images/JohnsShop.png b/assets/images/JohnsShop.png Binary files differnew file mode 100644 index 0000000..5e32ddd --- /dev/null +++ b/assets/images/JohnsShop.png diff --git a/src/assets.c b/src/assets.c index eb5c888..72def7e 100644 --- a/src/assets.c +++ b/src/assets.c @@ -15,6 +15,7 @@ const char textureAssetPaths[TEXTURE_ASSET_COUNT][FT_NAMEMAX] = { "trash.png", "medicalTrash.png", "John.png", + "JohnsShop.png", "Ron.png", "background1.png", "background2.png", diff --git a/src/assets.h b/src/assets.h index fb2b660..6f9f1f0 100644 --- a/src/assets.h +++ b/src/assets.h @@ -4,7 +4,7 @@ #ifndef ASSETS_H #define ASSETS_H -#define TEXTURE_ASSET_COUNT 19 +#define TEXTURE_ASSET_COUNT 20 #define IMAGE_ASSET_COUNT 1 #define SHADER_ASSET_COUNT 4 #define MODEL_ASSET_COUNT 4 @@ -32,6 +32,7 @@ enum { TRASH_TEXTURE, MEDICAL_TRASH_TEXTURE, JOHN_TEXTURE, + JOHNS_SHOP_TEXTURE, RON_TEXTURE, BACKGROUND1_TEXTURE, BACKGROUND2_TEXTURE, diff --git a/src/entities/johnsStore.c b/src/entities/johnsStore.c index 5a38bd7..e3f4908 100644 --- a/src/entities/johnsStore.c +++ b/src/entities/johnsStore.c @@ -2,6 +2,9 @@ void initJohnsStore(Entity* entity) { + int width = 6; + int height = 6; + Color colors[] = { WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, BLACK, BLACK, BLACK, BLACK, WHITE, @@ -10,19 +13,9 @@ void initJohnsStore(Entity* entity) WHITE, BLACK, BLACK, BLACK, BLACK, WHITE, WHITE, WHITE, BLACK, BLACK, WHITE, WHITE }; - - int width = 6; - int height = 6; - - Image cubemap = (Image){ - .data = colors, - .width = width, - .height = height, - .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, - .mipmaps = 1 - }; - entity->data = (void*)createEntityBuilding(cubemap); + entity->data = (void*)createEntityBuilding( + colorsToImage(colors, width, height)); EntityBuilding* building = (EntityBuilding*)entity->data; entity->box = GetModelBoundingBox(building->model); } @@ -30,7 +23,11 @@ void initJohnsStore(Entity* entity) void updateJohnsStore(Entity* entity, Game* game) { EntityBuilding* building = (EntityBuilding*)entity->data; + + building->model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = + game->assets.textures[JOHNS_SHOP_TEXTURE]; DrawModel(building->model, entity->position, 1.0, WHITE); + DrawBoundingBox(entity->box, RED); } diff --git a/src/entities/johnsStore.h b/src/entities/johnsStore.h index fd84214..c377741 100644 --- a/src/entities/johnsStore.h +++ b/src/entities/johnsStore.h @@ -1,6 +1,7 @@ #include "game.h" #include "entity.h" #include "utils.h" +#include "assets.h" #ifndef JOHNS_STORE_H #define JOHNS_STORE_H diff --git a/src/entity.c b/src/entity.c index f6d51bf..fa3a414 100644 --- a/src/entity.c +++ b/src/entity.c @@ -228,10 +228,23 @@ void setEntityPosition(Entity* entity, Vector3 position) void placeEntityOnGround(Entity* entity, const World* world) { Vector3 position = entity->position; + + if (entity->id == ENTITY_NONE) + { + return; + } position.y = getWorldHeightAtLocation( world, entity->position.x, entity->position.z); - position.y += (entity->box.max.y - entity->box.min.y) / 2.0; + + if (entityIsBuilding(entity->id)) + { + position.y += ENTITY_BUILDING_GROUND_OFFSET; + } + else + { + position.y += (entity->box.max.y - entity->box.min.y) / 2.0; + } setEntityPosition(entity, position); } diff --git a/src/entity.h b/src/entity.h index 66e1973..5f03e52 100644 --- a/src/entity.h +++ b/src/entity.h @@ -13,7 +13,8 @@ #define INTERACTION_LABEL_MAX 32 #define INTERACTION_CHAT_MAX 256 -#define ENTITY_BUILDING_CUBE_SIZE (Vector3){2.0, 2.0, 2.0} +#define ENTITY_BUILDING_CUBE_SIZE (Vector3){4.0, 4.0, 4.0} +#define ENTITY_BUILDING_GROUND_OFFSET 0.03 typedef int8_t EntityId; typedef enum InteractionCommand InteractionCommand; diff --git a/src/utils.c b/src/utils.c index 02d7388..22ed7b4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -34,4 +34,15 @@ Vector3 randomDirection3(int seed, int* nextSeed) return Vector3Normalize(direction); } +Image colorsToImage(Color* colors, int width, int height) +{ + return (Image){ + .data = colors, + .width = width, + .height = height, + .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, + .mipmaps = 1 + }; +} + // Why does the universe feel strange to exist in? diff --git a/src/utils.h b/src/utils.h index fddfa9d..cccec85 100644 --- a/src/utils.h +++ b/src/utils.h @@ -70,4 +70,6 @@ typedef enum FTError { Vector2 randomDirection2(int seed, int* nextSeed); Vector3 randomDirection3(int seed, int* nextSeed); +Image colorsToImage(Color* colors, int width, int height); + #endif diff --git a/src/world.c b/src/world.c index fced57d..0096dbe 100644 --- a/src/world.c +++ b/src/world.c @@ -562,11 +562,16 @@ Seed generateWorldItems(World* world, Seed seed, int start, int end) Texture generateGroundTexture() { +#ifdef USE_WORLD_DEBUG_TEXTURE + Image image = GenImageChecked(WORLD_IMAGE_WIDTH, WORLD_IMAGE_HEIGHT, 1.0, + 1.0, BLACK, WHITE); +#else Image image = GenImageWhiteNoise(WORLD_IMAGE_WIDTH, WORLD_IMAGE_HEIGHT, WORLD_GROUND_IMAGE_NOISE); ImageBlurGaussian(&image, WORLD_GROUND_BLUR); ImageColorContrast(&image, WORLD_GROUND_CONTRAST); ImageColorTint(&image, WORLD_GROUND_COLOR); +#endif Texture texture = LoadTextureFromImage(image); UnloadImage(image); @@ -741,8 +746,9 @@ void generateWorldSamanthasPlace(World* world, const Assets* assets, Seed generateWorldJohnsShop(World* world, Color* colors, Seed seed, WorldUID* placeId, WorldUID* id) { + // Add John's shop entity. Vector3 position = Vector3Scale(world->size, 0.5); - position.x += 30.0; + position.x += 60.0; Entity johnsShop = createEntity(JOHNS_STORE, position); world->entities[*id] = johnsShop; world->places[*placeId] = *id; @@ -750,6 +756,25 @@ Seed generateWorldJohnsShop(World* world, Color* colors, Seed seed, *id = *id + 1; *placeId = *placeId + 1; + // Flatten out area. + float width = 8.0; + float height = 8.0; + + Vector2 pixelPosition = worldPositionToPixel(world, position.x, position.z); + /* pixelPosition.x -= width / 2.0; */ + /* pixelPosition.y -= height / 2.0; */ + pixelPosition.x -= 2.0; + pixelPosition.y -= 2.0; + + Rectangle area = (Rectangle){ + pixelPosition.x, + pixelPosition.y, + width, + height + }; + + averageOutAreaWorld(world, colors, area); + return seed; } @@ -796,13 +821,7 @@ World createWorld(Seed seed, const Assets* assets) seed = generateWorldPlaces(&world, assets, colors, seed, &id); // Heightmap model. - image = (Image){ - .data = colors, - .width = WORLD_IMAGE_WIDTH, - .height = WORLD_IMAGE_HEIGHT, - .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, - .mipmaps = 1 - }; + image = colorsToImage(colors, WORLD_IMAGE_WIDTH, WORLD_IMAGE_HEIGHT); Mesh mesh = GenMeshHeightmap(image, world.size); world.heightmap = LoadModelFromMesh(mesh); diff --git a/src/world.h b/src/world.h index 88c8ab2..723db8b 100644 --- a/src/world.h +++ b/src/world.h @@ -5,6 +5,8 @@ #ifndef WORLD_H #define WORLD_H +#define USE_WORLD_DEBUG_TEXTURE + #define WORLD_ENTITY_MAX 5000 #define WORLD_PLANT_COUNT 2500 #define WORLD_UTILITY_POLE_COUNT 25 |
