diff options
-rw-r--r-- | assets/images/trashcan.png | bin | 5300 -> 4682 bytes | |||
-rw-r--r-- | src/entity.c | 54 | ||||
-rw-r--r-- | src/entity.h | 4 | ||||
-rw-r--r-- | src/world.c | 15 | ||||
-rw-r--r-- | src/world.h | 3 |
5 files changed, 61 insertions, 15 deletions
diff --git a/assets/images/trashcan.png b/assets/images/trashcan.png Binary files differindex 96e0d1c..81bf552 100644 --- a/assets/images/trashcan.png +++ b/assets/images/trashcan.png diff --git a/src/entity.c b/src/entity.c index 8de3eab..329aed1 100644 --- a/src/entity.c +++ b/src/entity.c @@ -66,7 +66,8 @@ Entity createEntity(EntityId id, Vector3 position) break; case TRASHCAN: - entity.box = entityBoxFromScale(TRASHCAN_SCALE, 45.0, 60.0); + entity.box = entityBoxFromScale(TRASHCAN_SCALE, TRASHCAN_WIDTH, + TRASHCAN_HEIGHT); break; default: break; @@ -77,9 +78,44 @@ Entity createEntity(EntityId id, Vector3 position) return entity; } +void updateSamantha(Entity* entity, Game* game) +{ + // silly tv static effect. + game->assets.models[SAMANTHA_MODEL].materials[0] + .maps[MATERIAL_MAP_DIFFUSE].texture = + game->assets.textures[ + SAMANTHA_1_TEXTURE + ((int)(GetTime() * SAMANTHA_STATIC_SPEED) % + SAMANTHA_STATIC_FRAMES)]; + + DrawModel(game->assets.models[SAMANTHA_MODEL], entity->position, 1.0, + WHITE); +} + +void updateTrashcan(Entity* entity, Game* game) +{ + int frame = (int)(GetTime() * TRASHCAN_ANIMATION_SPEED) % TRASHCAN_FRAMES; + + Rectangle rect = (Rectangle){ + .x = frame * TRASHCAN_WIDTH, + .y = 0.0, + .width = TRASHCAN_WIDTH, + .height = TRASHCAN_HEIGHT + }; + + DrawBillboardRec( + game->player.camera, + game->assets.textures[TRASHCAN_TEXTURE], + rect, + entity->position, + (Vector2){TRASHCAN_SCALE + * (TRASHCAN_WIDTH / TRASHCAN_HEIGHT), + TRASHCAN_SCALE}, + WHITE); +} + void updateEntity(Entity* entity, Game* game) { - //DrawBoundingBox(entity->box, RED); + DrawBoundingBox(entity->box, RED); switch (entity->id) { @@ -109,20 +145,10 @@ void updateEntity(Entity* entity, Game* game) (Vector2){POND_SIZE * 2.5, POND_SIZE * 2.5}, BLUE); break; case SAMANTHA: - // silly tv static effect - game->assets.models[SAMANTHA_MODEL].materials[0] - .maps[MATERIAL_MAP_DIFFUSE].texture = - game->assets.textures[ - SAMANTHA_1_TEXTURE + ((int)(GetTime() * SAMANTHA_STATIC_SPEED) % - SAMANTHA_STATIC_FRAMES)]; - - DrawModel(game->assets.models[SAMANTHA_MODEL], entity->position, 1.0, - WHITE); + updateSamantha(entity, game); break; case TRASHCAN: - DrawBillboard(game->player.camera, - game->assets.textures[TRASHCAN_TEXTURE], - entity->position, FLOWER_SCALE, WHITE); + updateTrashcan(entity, game); break; default: break; diff --git a/src/entity.h b/src/entity.h index 8078cfc..839a847 100644 --- a/src/entity.h +++ b/src/entity.h @@ -27,6 +27,10 @@ #define SAMANTHAS_SPOT_HEIGHT 5 #define TRASHCAN_SCALE 2.0 +#define TRASHCAN_FRAMES 4 +#define TRASHCAN_ANIMATION_SPEED 6 +#define TRASHCAN_WIDTH 45.0 +#define TRASHCAN_HEIGHT 60.0 typedef int8_t EntityId; diff --git a/src/world.c b/src/world.c index 74c5fec..0dde09d 100644 --- a/src/world.c +++ b/src/world.c @@ -514,6 +514,21 @@ void generateWorldSamanthasPlace(World* world, Color* heightmap, SAMANTHA_OFFSET)); world->entities[*placeId] = samantha; *placeId = *placeId + 1; + + // Trash yippee! + Vector3 trashcanPosition = (Vector3){-SAMANTHAS_SPOT, + 0.0, + SAMANTHAS_SPOT_SIZE / 1.5}; + + for (int index = 0; index < SAMANTHAS_SPOT_TRASHCAN_COUNT; ++index) + { + Entity trashcan = createEntity(TRASHCAN, + Vector3Add(trashcanPosition, center)); + world->entities[*placeId] = trashcan; + *placeId = *placeId + 1; + trashcanPosition.x += (float)(SAMANTHAS_SPOT_SIZE * 2.0) + / SAMANTHAS_SPOT_TRASHCAN_COUNT; + } } Seed generateWorldPlants(World* world, Seed seed, int start, int end) diff --git a/src/world.h b/src/world.h index 79bb98e..57f6acf 100644 --- a/src/world.h +++ b/src/world.h @@ -5,7 +5,7 @@ #ifndef WORLD_H #define WORLD_H -#define WORLD_ENTITY_MAX 5001 +#define WORLD_ENTITY_MAX 5000 #define WORLD_PLANT_COUNT 2500 #define WORLD_UTILITY_POLE_COUNT 25 #define WORLD_PLACE_COUNT 2 @@ -35,6 +35,7 @@ #define WORLD_CHARACTER_COUNT 0 #define SAMANTHA_OFFSET (Vector3){0.0, 0.0, 2.0} +#define SAMANTHAS_SPOT_TRASHCAN_COUNT 5 // UID for anything in the world. typedef int16_t WorldUID; |