aboutsummaryrefslogtreecommitdiff
path: root/src/engine/animator.c
diff options
context:
space:
mode:
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)