
Well, if you've always wanted to make RPGs or a Legend of Zelda style game(shown above) First off, we will decide if you want basic four-way movement(Up,Down,Left,Right) or eight-way (Up,Up-Right,Right,Right-Down, Down, Down-Left, Left and Left-Up) Actually, in my opinion, eight-way is simpler to make, but choose what you want, both are pretty easy. Ok, stay here for four-way, scroll down for eight-way.
Basic Four-Way Movement
First, make four sprites. Name them sprCharR, sprCharD, sprCharL and sprCharU. Now, the sprCharR will be your main character facing right, sprCharU will be him facing up, and so on. you can use this image for them if you want:

Yay! Ok, you have all the sprites to make an RPG! (well, your character anyway.) once you have them, continue on!
Well go to the CREATE event.
global.facing="
"; global.moving=falseThis code establishes two variables. facing and moving.
If you don't know what a variable is, scroll way down.
If you do, continue on to the STEP event.
if (global.facing="R"
{sprite_index=sprCharR}if (global.facing="
"
{sprite_index=sprCharD}if (global.facing="L"
{sprite_index=sprCharL}if (global.facing="U"
{sprite_index=sprCharU} Ok, first off, what this does here is say, "If you are facing down '"
"' change the 'sprite' or image of your character and so on untill you get to moving up, left, right." This is why variables are so important, this way, if we say, 'global.facing="L"' he will automatically look left! Now, if you used the sprite I gave, he has four subimages. The first and third one look like he's standing doesn't it? Well, we will use that first image for his standing pose. if global.moving=true{image_speed=0.2}
else if global.moving=false{image_speed=0; image_index=0}
Well, this says, "If you are moving 'global.moving=true' then have him animate at the speed of .2 times a second." Now since we didn't assign when it is "moving" and not, we must assign this. So, put this right under it.
if (keyboard_check(vk_left) or keyboard_check(vk_up) or keyboard_check(vk_right) or keyboard_check(vk_down)){
global.moving=true
} else global.moving=false
OK! Big code, not really. You might be thinking! What the heck?! I'll will guide you step by step if you are confused. Ok, all it says is, "If you are not pressing the up key, down key, left key, or right key, then global.moving=false, but if you are pressing any one of those, global.moving=true." Hopefully, that broke it down enough for you. If not... um... look up keyboard_check in the help file. At this point, you can do two things, now, as of now, what he will do is, if you press any button, animate like he's walking, but he won't move, and he won't change direction. We will fix that in the next code. With this code, you can either put it all in the step, or split it into the keyboard pressed buttons.
[u] In the Step [/u]
if global.moving=false{
motion_set(0,0)
}
if keyboard_check(vk_left) {motion_set(180,2); global.facing="L"}
if keyboard_check(vk_up) {motion_set(90,2); global.facing="U"}
if keyboard_check(vk_right){motion_set(0,2); global.facing="R"}
if keyboard_check(vk_down) {motion_set(270,2); global.facing="
"}Ok, "If global.moving=false, set movement for nothing. If you are pressing left, move set movement to 180(left) sat the speed of 2, so on and so on." There, if you followed that method, then you are done. If you wanted to use the "In the keyboard press" continue reading.
[u] In The Keyboard Press[/u]
It's really the same thing, but easier to see. First of all, keep this in the STEP event, if global.moving=false{
motion_set(0,0)
}
In the PRESS<LEFT> event,
motion_set(180,2); global.facing="L"
In the PRESS<UP> event,
motion_set(90,2); global.facing="U"
In the PRESS<RIGHT> event,
motion_set(0,2); global.facing="R"
In the PRESS<
OWN> event,motion_set(270,2); global.facing="
"There you have it. You have made a four-way top-down character!
Complex Eight-Way Movement
We will be using the Legend of Zelda as an example here.
First, make four sprites. Name them sprLinkR, sprLinkD, sprLinkL and sprLinkU. Now, the sprLinkR will be your main character facing right, sprLinkU will be him facing up, and so on. you can use this image for them if you want:

Yay! Ok, you have all the sprites to make The Legend of Zelda! (well, Link anyway.) once you have them, continue on!
Uh oh! I haven't gotten to finish yet! Give me a day or two and it will be finished ok?
Comments
Loading comments...