Actionscripting a Fighting Game (multiple questions)
I'm currently working on a simple fighting game on Flash CS3, coded with Actionscript 2.0
I have the basic setup done, just need to make a few more features, including more playable characters, move combos, and a Mortal Kombat style fatality. What I've already done is a simple one round game, with just 4 moves, low kick, high kick, low punch, high punch, jump kick, jump punch, and guard.
---
Problem #1: Move Combos
The combos are not complicated, just pressing two keys at the same time (e.g. instead of just a low kick, pressing low kick and high kick simultaneously will activate a certain combo, instead of just low kicking or high kicking)
Here's a snippet of code:
Code:
if (!jump1 && this.punch == 0 && !dead1 && !Key.isDown(87)) {
if (Key.isDown(85)) {
this.gotoAndPlay("punch1");
}
if (Key.isDown(79)) {
this.gotoAndPlay("punch2");
}
if (Key.isDown(73)) {
this.gotoAndPlay("kick1");
}
if (Key.isDown(74)) {
this.gotoAndPlay("kick2");
}
}
if (this.punch == 0 && jump1) {
if (Key.isDown(85) or Key.isDown(79)) {
this.gotoAndPlay("jumppunch");
}
if (Key.isDown(73) or Key.isDown(74)) {
this.gotoAndPlay("jumpkick");
}
}
If a certain key is pressed, it will play an animation of the assigned action, but how do I make it so if two keys are pressed at the same time, it will play an altogether different animation?
Problem #2: A Mortal Kombat style, finishing Fatality
I thought I had this down before, I made a code where a certain key (reserved for the Fatality move) can only be pressed when the opponent’s health reaches a certain level, e.g. :
Code:
if ((health2<=10) && Key.isDown(85)) {
this.gotoAndPlay("fatality");
}
So, if the opponent’s (in this case, player 2)’s health is not below 10, the fatality key can’t be pressed, so a fatality cannot be performed until the opponent’s health is below 10
The problem is, what if both players use a fatality at the same time? It would cause chaos, so if by chance both player 1 and player 2 can do a fatality to each other (both’s health below 10), how do we prevent player 2 from activating a fatality when player 1 activated his fatality first (and vice versa)?
---
Help will be greatly appreciated, and if there isn't enough code to set an example, I can send you the actual .fla file of the prototype (not in english though), just tell me if you need it
Thanks in advance ^^