diff options
author | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-02-21 18:50:36 +0000 |
---|---|---|
committer | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-02-21 18:50:36 +0000 |
commit | c11c0383fc4609dd67012d9e3aa44b7fa58c999c (patch) | |
tree | 6152ba5d513b98b617d85b01d44068b8abf1d1ab /src/clicky.c | |
parent | 2416dc256e53c431c5226827d90cf504f190f9ec (diff) | |
download | PenguinYippies-c11c0383fc4609dd67012d9e3aa44b7fa58c999c.tar.gz PenguinYippies-c11c0383fc4609dd67012d9e3aa44b7fa58c999c.tar.bz2 PenguinYippies-c11c0383fc4609dd67012d9e3aa44b7fa58c999c.zip |
Better animation and clicky stuff
Diffstat (limited to 'src/clicky.c')
-rw-r--r-- | src/clicky.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/clicky.c b/src/clicky.c index a1ab910..d8d64f9 100644 --- a/src/clicky.c +++ b/src/clicky.c @@ -1,10 +1,26 @@ #include "clicky.h" #include "game.h" #include "assets.h" +#include <raylib.h> + +void updateClicky(Game* game, Clicky* clicky) +{ + clicky->updateCB(game, clicky); +} void updatePenguinLol(Game* game, Clicky* clicky) { + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + { + replayAnimation(&clicky->animation); + } + // Run animation and update. + runAnimation(&clicky->animation); + + Texture texture = clicky->animation.texture; + DrawTexturePro(texture, (Rectangle){0.0, 0.0, texture.width, texture.height}, + clicky->rect, Vector2Zero(), 0.0, WHITE); } Clicky createPenguinLolClicky(Game* game) @@ -12,14 +28,13 @@ Clicky createPenguinLolClicky(Game* game) Clicky clicky; clicky.animation = createAnimation(&game->assets.animations[PENGUIN_LOL_ANIMATION], ANIMATION_DEFAULT_DELAY); - clicky.texture = &clicky.animation.texture; + clicky.animation.repeat = false; + clicky.texture = NULL; clicky.rect = (Rectangle){0.0, 0.0, 128.0, 128.0}; clicky.data = NULL; clicky.updateCB = updatePenguinLol; - runAnimation(&clicky.animation); - return clicky; } |