Advertisement
Tkap1

Untitled

Sep 27th, 2022
907
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1.  
  2.  
  3. attack_time += delta;
  4. while(attack_time >= attack_delay)
  5. {
  6.     attack_time -= attack_delay;
  7.    
  8.     attack_anim_active = true;
  9. }
  10.  
  11. if(attack_anim_active)
  12. {
  13.     float percent = attack_time / attack_delay;
  14.     int index_from_percent = (int)roundf(percent, attack_sprites.count);
  15.     sprite = attack_sprites[index_from_percent];
  16.     if(sprite == attack_sprites[attack_sprites.count - 1]) { attack_anim_active = false; }
  17. }
  18. else
  19. {
  20.     sprite = default_sprite_or_whatever;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement