Gw Temp

Menu

Tutorial - 'Basic ABS part one - Moving and attacking' by Stormshadow

An item about Gamemaker posted on

Blurb

kaworu writes a descriptive tutorial about making an Active Battle System in GameMaker, check it out everyone!

Body

Well this tutorial is for a basic ABS and is (hopefully) part one of a two part tutorial(if it gets posted, I'm asuming that you have followed the beginners tutorial which you can download from the GM mainsite. It is Zelda style (duh), and for simplicity reasons, I will use reference to Zelda for the names (which you can replace later if you want)

1.Setting up the resources.

First under sprites, add a group called "Link", inside "Link" create two more groups, one called "walk", and the other called "attack". Under the "walk" sub-group, add a new sprite, this should be a gif of Link walking upwards (I suggest you use the ones on GSArchives). Set the Origin at the light green dot on Link's hat. Name this sprite "sprwalkup". Close the box and add another sprite, call this "sprwalkleft" and the sprite should be of Link walking left. Again the Origin should be the light green dot located on Link's hat. Close this box, and repeat the process for "sprwalkdown" and "sprwalkright", using the correct sprites for the directions. Now under the "attack" group, add a new sprite, name it "sprslashup" and load up a gif of Link slashing away with his sword. Repeat the process again but for Link slashing his opponents.

2.Object and events

Go down to the "objects" heading on the sidebar and add a new object, name it "objplayer". Choose the sprite for this object, make it one of Link facing downwards(walking not slashing). Now add an event, for the left key being held down. Under that event, choose "execute a peice of code". This code should change the sprite so that Link is walking left, and also move to the left. It should look something like this...

sprite_index = sprwalkleft
x -=5;


Add another event, this time for te up key being held. Again, execute another peice of code, which says...

sprite_index = sprwalkup
y -=5;


Add events for both the down and right keys, using the following codes respectively
Down:
sprite_index = sprwalkdown
y +=5;

Right:
sprite_index = sprwalkright
x +=5;


Now click on "ok", and save the file (for convinience purposes only). Create a new room, and add "objplayer" to the middle. Test the game, and you should notice that Link walks around, and can change direction. As an added bonus, he walks in eight directions.

3.Attacking

So he can walk, but we need him to attack. Return to "objplayer" and add a new event, this time for the spacebar being pressed (not held down) Excecute another peice of code, this one will check what direction Link is facing, and slash the sword in that direction...

if sprite_index = sprwalkup then
{
sprite_index = sprslashup
alarm[0] = 7
}
if sprite_index = sprwalkdown then
{
sprite_index = sprslashdown
alarm[1] = 6
}
if sprite_index = sprwalkleft then
{
sprite_index = sprslashleft
alarm[2] = 7
}
if sprite_index = sprwalkright then
{
sprite_index = sprslashright
alarm[3] = 7
}

If you test the game now, you will notice that when Link slashes, he carries on until you change direction. What we need to do now is to add events for the alarms. Create a new event, "Alarm 0". Execute another code, this will simply be
sprite_index = sprwalkup
notice that when testing it, if Link slashes up, then he will stop after one swing, but all other directions will carry on. Add a new event for "Alarm 1", and use the code
sprite_index = sprwalkdown
Now repeat the process for Alarms 2 and 3, using the following codes...
Alarm 2:
sprite_index = sprwalkleft


Alarm 3:
sprite_index = sprwalkright


Now when slashing, Link will stop after one swing in any direction. Save the file again if you want.

4.Conclusion

Well now you can see Link move and attack, and get used to many of the basic features which will hopefully be introduced in my next tutorial. The next tutorial will include adding monsters, rupees and (hopefully) health and magic.

-Kaworu-
Is there anyone cuter?