Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 08:27:12 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Combo System animation
Pages: [1]
Print
Author Topic: Combo System animation  (Read 633 times)
unknown3344
Level 0
*


View Profile
« on: March 02, 2015, 08:41:49 PM »

I'm developing a combo system for the player so when the player presses x multiple times he preforms a combo. The combo system is working when the player presses the x button multiple times slowly. but when mashing the x button it goes to  the second sprite before the animation ends. I've also tried some other ways of doing it but with no luck.

Here is the best I could come up with after a lot of research and debugging:

Create event:
Code:
attack = false;

//timer veriable used for combos
comboTimer = 0;

combo = 0;

step event:
Code:
///Attack mechanic

comboTimer -= 1;

if(comboTimer < 0){
    combo = 0;
}

//show_debug_message(image_index);

if (attackKey){
   comboTimer = 15;
   
    if (combo == 0) {
       
        attack = 1;
        combo += 1;
        sprite_index=spr_thief_attack;
        image_index=0;
        image_speed = 0.2;
        alarm[0]=20; exit;
    }
   if (combo == 1) {
       
      attack = 1;
      combo += 1;
      sprite_index=spr_thief_attack_combo1;
      image_index=0;
      image_speed = 0.2;
      alarm[0]=10; exit;
   }
   
   if (combo == 2) {
       
      attack = 1;
      combo += 1;
      sprite_index=spr_thief_attack_combo2;
      image_index=0;
      image_speed = 0.2;
      alarm[0]=10; exit;
   }
}

if(combo > 2){
    combo = 0;
}





Alarm 0 event:
Code:
attack = 0;

I would also appreciate it if someone pointed me to some good practices in implementing combo animations if this code is not good enough.

I'm also wondering if ending the animation before going to the next sprite in combo systems is good game design or not.

Any help would be appreciated.
« Last Edit: March 02, 2015, 08:46:52 PM by unknown3344 » Logged
Snowstorm
Level 0
***


It's supposed to be pixel art, but whatever.


View Profile WWW
« Reply #1 on: March 03, 2015, 06:25:47 AM »

The combo system that you've implemented is very good! However, I don't think it's suitable for going to the next animation after the previous one ends because the way it's set up will make it so it immediately switches animations when the attack key is pressed.

As for ending the animation before displaying the next sprite, I think it would be confusing to the player because it would make them feel like that their input to attack would be 'delayed' because the previous animation is still playing. Of course, this shouldn't be a problem if the animations are quick!

If you still really want this, however, I think the best way to implement "animation fluency" I'll call it, is to check if the image_index of the current sprite is equal to the number of the last frame (e.g. if there are 8 frames, the last frame would be 7). If so, then set the new sprite.
Logged

Craig
Snowstorm
unknown3344
Level 0
*


View Profile
« Reply #2 on: March 03, 2015, 07:57:49 AM »

Thanks for clarifying that ending the animation before the start of the next attack(combo) would be considered a bad game design.

I haven't implemented any combo systems before so I thought that the attack animation should finish before starting the next attack animation. However, if I would've implemented this I don't think it would be a problem as the sprites consists of 2-3 frames per attack animation.
Logged
Layl
Level 3
***

professional jerkface


View Profile WWW
« Reply #3 on: March 03, 2015, 09:31:49 AM »

If you want to look at improving the code a bit more, it might be worth looking into making it a finite state machine. Something very limited, no need to have a whole inheritance system for states here. If you go this route try to make the system reusable for other characters' animations.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic