diff options
Diffstat (limited to 'src/engine/animator.c')
-rw-r--r-- | src/engine/animator.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/engine/animator.c b/src/engine/animator.c index 71d0582..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) @@ -45,5 +62,4 @@ void hh_show_quad(uint16_t *idx, hh_s_rendering* in) { temp.position_y = CLAMP(in->fam.position_y, -16, HH_PPU_SCREEN_HEIGHT); temp.position_x = CLAMP(in->fam.position_x, -16, HH_PPU_SCREEN_WIDTH); hh_ppu_update_foreground(++*idx, temp); - temp.tilemap_index++; } |