diff options
Diffstat (limited to 'src/entities/trashcan.c')
| -rw-r--r-- | src/entities/trashcan.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/entities/trashcan.c b/src/entities/trashcan.c new file mode 100644 index 0000000..880bc4c --- /dev/null +++ b/src/entities/trashcan.c @@ -0,0 +1,28 @@ +#include "trashcan.h" + +void initTrashcan(Entity* entity) +{ + entity->box = entityBoxFromScale(TRASHCAN_SCALE, TRASHCAN_WIDTH, + TRASHCAN_HEIGHT); +} + +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); +} |
