aboutsummaryrefslogtreecommitdiff
path: root/src/engine/animator.c
diff options
context:
space:
mode:
authorUnavailableDev <ggwildplay@gmail.com>2023-04-06 21:36:24 +0200
committerUnavailableDev <ggwildplay@gmail.com>2023-04-06 21:36:24 +0200
commite88c48ae60dd48542e44b0cc244b191c91782681 (patch)
tree344243247b21a93311a9cc2173fbddb2d126c040 /src/engine/animator.c
parent03748610041bcc8ec7a7743e9a5fb35c06731fa0 (diff)
random shop items + animations
Diffstat (limited to 'src/engine/animator.c')
-rw-r--r--src/engine/animator.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/engine/animator.c b/src/engine/animator.c
index 0811ba7..f188096 100644
--- a/src/engine/animator.c
+++ b/src/engine/animator.c
@@ -6,21 +6,38 @@
#define hh_white_palette 6
+#define hh_animate_cycle 4
void hh_animate_hit(hh_s_rendering* in, bool hit) {
if (hit) {
in->fam.palette_index = hh_white_palette;
- } else {
+ in->cooldown = hh_animate_cycle;
+ } else if(in->cooldown == 0) {
in->fam.palette_index = in->palette;
+ } else {
+ if (in->cooldown > 0) {
+ in->cooldown--;
+ }
}
}
void hh_animate(hh_s_rendering* in, uint16_t start, uint16_t end, uint8_t step) {
- if (in->fam.tilemap_index >= start && in->fam.tilemap_index < end) {
- in->fam.tilemap_index += step;
- } else {// rollover
+ if (in->fam.tilemap_index < start) {//check for sudden animation change
in->fam.tilemap_index = start;
+ in->cooldown = hh_animate_cycle;
+ } else {
+ if (in->cooldown-- == 0) {
+
+ if (in->fam.tilemap_index < end) {
+ in->fam.tilemap_index += step;
+ } else {// rollover
+ in->fam.tilemap_index = start;
+ }
+ in->cooldown = hh_animate_cycle;
+ }
+
}
+
}
//TODO: if entity not inside of screen, don't update idx (problems with old idx not being overwritten anymore)