-
[ HELP ] Make a basic fighting game?
Hey Flashkit, I am median programming with actionscript, already tried in several places a way to create a set of basic combos and fight with enemies but did not think, does anyone know how to do or som interesting tutorial teaching such a thing?
Thank. CrazY :D
-
If you mean turn-based (like Pokemon or such), I do
I use a small system. Most of my projects depend on a sole variable located in a layer within my project:
_root.anythingYouWantHere = X
For this instance, we may use:
_root.Turn = 0
_root.hp = 100 //HP for our hero
_root.eHp = 100 //HP for our baddie
Then create two objects: one for the player and one for the enemy. Make different animations for their attacks. (make objects within the objects and animate them from there) Just make those easily distinguishable (like changing colors); they do not have to be über elaborated. Just make sure that the last frame has this script:
onEnterFrame = function(){
_root.hpz -= X //X stands for the HP you want to take away from z, which is the HP for either the hero or the baddie.
_root.y.gotoAndStop(1) //y applies for either the hero or the baddie.
}
Then add some buttons for your new hero's attacks. In this case, my hero slashes with his sword everytime you press the attack button (and the _root.Turn is properly activated).
For the buttons' scripts, use:
on(press)-on(release){ //I leave that to your heart's content.
if(_root.Turn == 0){ //It will be my hero's turn to attack each time 0 is set as _root.Turn's value.
_root.hero.gotoAndStop(X) //First of all, make sure your character (hero) is exported to actionscript. X stands for the frame where the specified attack is.
}
}
This script goes for the baddie:
onClipEvent(load-enterframe){ //Once again, to your heart's content
if(_root.Turn == 1){
| if(Math.random()<X) { //X stands for the chance of a specific attack of ocurring.
| this.gotoAndStop(Y) //Y stands for the frame you want.
| }
}
}
THe script marked with | should be repeated as many frames as you have. WARNING: Start taking apart small pieces from a 100% (e.g if I have 4 frames for attacks it would be around 25% per attack, or something like that) but make sure the whole numbers that are a chance, when added, must always give 100.
Place them side by side, facing each other. Place the buttons in a comfy position.
Add two dynamic text fields, make them easily distinguishable between each other. Stablish the Var for each one: _root.hp and _root.eHp.
This small guide should help you build your game. It is somewhat still in brute, but with your skill I am confident you can polish this script into something far smoother.
I came too late, sorry. BUt I hope this helps you!
--Android Flash
-
I was thinking of something more advanced like a street fighter, mortal kombat or a game by common platforms with combos, you have a game with this code example that happened to me?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|