Forum Topic: plataformer help with combo AS2

(127 views • 5 replies)

This topic is 1 page long.

<< < > >>
Angry

damianemtum

Reply To Post Reply & Quote

Posted at: 6/12/09 03:16 AM

damianemtum EVIL LEVEL 06

Sign-Up: 11/25/05

Posts: 5

hi,

im making a plataformer game i already have movement , stages, health, etc etc

but im having problems with the "combos"

i want that my char when i press (for example "spacebar" ) hit and when i press spacebar again it makes another different hit and so

i know that i have to draw different frames inside the movieclip for each hit

but i dont know how to make it works :S

any help?


None

Afro-Ninja

Reply To Post Reply & Quote

Posted at: 6/12/09 03:45 AM

Afro-Ninja EVIL LEVEL 37

Sign-Up: 03/02/02

Posts: 13,466

At 6/12/09 03:16 AM, damianemtum wrote: hi,

im making a plataformer game i already have movement , stages, health, etc etc

but im having problems with the "combos"

i want that my char when i press (for example "spacebar" ) hit and when i press spacebar again it makes another different hit and so

i know that i have to draw different frames inside the movieclip for each hit

but i dont know how to make it works :S

any help?

well... a basic way is to just check the frame position and make a judgment on if they correctly followed the combo or not

so let's say attack 1 has 50 frames. Near the end, from 40-50, is when the second part of the combo can be activated. when you evaluate the key press for space, check to see what attack animation they are on and what the current frame is. if it's attack one and in between 40-50, then switch to the next animation. otherwise reset the first one or don't do one at all.

there's a ton of ways to approach this because there are a ton of ways to organize and nest your attack animations inside a character sprite. and you can also choose between things like evaluating frame position and setting booleans like 'okToCombo' on the actual frames of the attack animation.

BBS Signature

Happy

Bezman

Reply To Post Reply & Quote

Posted at: 6/12/09 04:07 AM

Bezman FAB LEVEL 29

Sign-Up: 08/16/01

Posts: 2,764

At 6/12/09 03:16 AM, damianemtum wrote: hi,

im making a plataformer game i already have movement , stages, health, etc etc

but im having problems with the "combos"

i want that my char when i press (for example "spacebar" ) hit and when i press spacebar again it makes another different hit and so

i know that i have to draw different frames inside the movieclip for each hit

but i dont know how to make it works :S

any help?

As with most things, there'll be many ways to do this. I'll suggest one possible way but bear in mind that
1) I technically use AS1
2) I openly admit I'm not a programmer - just someone who's been (just barely) willing to do so in the past in order to realise a few of my simpler ideas.

By the way, I'll leave the syntax up to you, rarely going further than pseudocode.

Have a boolean flag called something like 'punching'.

When space is pressed, if (!punching) {gotoAndPlay(the first frame of the punching animation; punching=true; combo=true;}

Without the boolean check, you'd be able to punch as fast as the key is hit.

In the animation, I'd personally have x punches, each lasting n frames with the fist/foot making 'contact' and pausing for the last m frames. x is the maximum combo you want folk to be able to do and m is the timeframe of opportunity for hitting the combo. n should be defined by how quickly you want the character to be able to strike, how quickly you want players to need to press the button... consider both aesthetics and gameplay. Experiment and maybe research some classic console games with the aid of a stopwatch.

I'd personally keep n and m constant, since I like simplicity - specially in flash games - but testing may reveal that it's better to speed it up as the combo goes on or vary the tempo. And of course it's a design issue I'll largely leave up to you.

Anyway, on each little punch animation, you've got the last m frames where if a user clicks, they should hit again. Have damage be dealt on the n-mth frame (e.g. if n is 25 and m is 7, deal damage on the 18th frame) Over the last m frames, have code:

if they hit the button, if (combo) gotoAndPlay the first frame of the next hit animation.

On every other frame, if they hit the button {combo=false;}

This will stop folk just hammering the button as quickly as they can - a pet peeve of mine. Remember to signal everything visually to players - including a 'broken combo' - maybe even have code to pop up a big message on the stage here if combos are a big focus.

Then on the nth frame, gotoAndPlay the non-fighting animation. The only way the nth frame is reached would be by the button not having been hit by then. (or the button having been hit prematurely)

Of course, you have to decide - should the character be able to move during combos? Should there be a combo tree? The tree could be easily done as an expansion of the system I outline above. Moving during combos, I leave up to you. It could be perhaps done by having left/right not move the character directly during a combo but rather set a flag to say which direction the next hit will be in. Then use a tree system. Or maybe have two attack buttons - one for each side.

Of course, if you don't need variation between punches (either in timing or graphically), the entire thing could be done with n frames, no need to have the repeats, but I'd strongly recommend it - if only to give some graphical 'reward' to those that access the combo, as well as signalling that they've done so.

As I always say, you can get far with just the basic variables, gotoAndPlay and some thinking. Remember - Pico's School was originally made in Flash 3!

Hope that was intelligible! :-)


None

wasup12

Reply To Post Reply & Quote

Posted at: 6/12/09 01:25 PM

wasup12 NEUTRAL LEVEL 08

Sign-Up: 12/16/07

Posts: 382

Heh, I designed one recently. Heres a snippet of it, to get the idea.

if(Key.isDown(attackKey) && attack1Done == true && velocityX == 0 && attack1Allowed == true && attack4Done == true && attackKeyDown == false)
			{
				this.gotoAndStop("attack1");
				attack1Done = false;
				attack1Toggled = true;
				attackTimer = 0;
				attack2Done = true;
				attack2Allowed = true;
				attack4Toggled = false;
				attackKeyDown = true;
					
			}
		if(attack1Toggled == true)
			{
				attackTimer++;
				attack1Allowed = false;
				if(attackTimer > timeAllowedAttack)
					{
						defualtAttack();
					}
			}

Be reminded that's only the first attack. I determine if the attack is done by putting some AS at the end of the frame of the frames playing.

BBS Signature

None

damianemtum

Reply To Post Reply & Quote

Posted at: 6/20/09 10:50 AM

damianemtum EVIL LEVEL 06

Sign-Up: 11/25/05

Posts: 5

i think i made it :)!! thanks to all the geeks


None

dailyderek

Reply To Post Reply & Quote

Posted at: 6/22/09 10:47 AM

dailyderek LIGHT LEVEL 12

Sign-Up: 10/28/07

Posts: 129

i could have helped

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 10:59 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!