This tutorial will teach you, step by step, how to make an RPG movement, like the one in the Game Boy Pokemon game. This will also utilize and teach you the basics of Grouping objects too.

Ok, first, create an Active Object with the dimensions of 32x32. Leave the hotspot in the top-left pixel. Call the object "PLAYER"

Now you'll need some detectors, one for the TOP, BOTTOM, RIGHT and LEFT of the character. So, make them (again, in 32x32, and again, leave the hotspot in the top left pixel). We need these detectors to stop the player from walking through backdrops. Call them by their respective names, ie, call one UP, DOWN, LEFT and the last RIGHT. And make them 8 pixels by 8 and centre them in the 32x32 frame. Understand?

Ok, first of all we need to position the detectors. So:

ALWAYS:

Set Position of UP at 0,-32 from PLAYER
Set Position of DOWN at 0,32 from PLAYER
Set Position of LEFT at -32,0 from PLAYER
Set Position of RIGHT at 32,0 from PLAYER

Ok, so when you run your klik program, you should see four detectors, maybe overlapping your character. If they are, then you've done it wrong. Fiddle around, and once you've fixed it, SAVE your current project.
______________

Ok, now, we are going to make the PLAYER move UP. (btw, when I put something like "X UP, it means its negated)

REPEAT WHILE PLAYER MOVES UP
ALTERABLE VALUE A OF PLAYER = 0
ALTERABLE VALUE B OF PLAYER = 0
X UP IS OVERLAPPING BACKDROP

Set Alterable Value A of Player = 1
Set Alterable Value B of Player = 32
Activate Group "UP"


______________

Ok, now, we are going to make the PLAYER move DOWN.

REPEAT WHILE PLAYER MOVES DOWN
ALTERABLE VALUE A OF PLAYER = 0
ALTERABLE VALUE B OF PLAYER = 0
X DOWN IS OVERLAPPING BACKDROP

Set Alterable Value A of Player = 2
Set Alterable Value B of Player = 32
Activate Group "DOWN"


______________

Now we move him LEFT

REPEAT WHILE PLAYER MOVES LEFT
ALTERABLE VALUE A OF PLAYER = 0
ALTERABLE VALUE B OF PLAYER = 0
X LEFT IS OVERLAPPING BACKDROP

Set Alterable Value A of Player = 3
Set Alterable Value B of Player = 32
Activate Group "LEFT"


______________

And finally, we'll move the Player RIGHT

REPEAT WHILE PLAYER MOVES RIGHT
ALTERABLE VALUE A OF PLAYER = 0
ALTERABLE VALUE B OF PLAYER = 0
X RIGHT IS OVERLAPPING BACKDROP

Set Alterable Value A of Player = 4
Set Alterable Value B of Player = 32
Activate Group "RIGHT"

Got all that? Now save your game. We're going to move onto the group section now. These next events allow the player to complete their movement according to their directions

______________

Ok now. Create a new group and call it UP. Ensure the group is NOT active at the start of the frame. If you look back through the code, there are parts which say "activate Group whatever"; thats when this part will be activated; when you press the Up key. Ok, so, add the following events:

EVERY 00.01 SECONDS
ALTERABLE VALUE B OF PLAYER > 0
ALTERABLE VALUE A OF PLAYER = 1

Subtract 2 from Alterable Value B of PLAYER
Set Y Position to Y ("PLAYER")-2

ALTERABLE VALUE B OF PLAYER = 0

Set Alterable Value A of Player to 0

Now test the game. The player should only be able to move DOWN now, and no other direction. Save it!

_______________

Now we'll move the Player RIGHT.

EVERY 00.01 SECONDS
ALTERABLE VALUE B OF PLAYER > 0
ALTERABLE VALUE A OF PLAYER = 4

Subtract 2 from Alterable Value B of PLAYER
Set X Position to X ("PLAYER")+2

ALTERABLE VALUE B = 0

Set Alterable Value A to 0


_______________

Now we'll move the Player LEFT.

EVERY 00.01 SECONDS
ALTERABLE VALUE B OF PLAYER > 0
ALTERABLE VALUE A OF PLAYER = 3

Subtract 2 from Alterable Value B of PLAYER
Set X Position to X ("PLAYER")-2

ALTERABLE VALUE B = 0

Set Alterable Value A to 0


_______________

And Finally, we'll move him DOWN

EVERY 00.01 SECONDS
ALTERABLE VALUE B OF PLAYER > 0
ALTERABLE VALUE A OF PLAYER = 2

Subtract 2 from Alterable Value B of PLAYER
Set Y Position to Y ("PLAYER")+2

ALTERABLE VALUE B = 0

Set Alterable Value A to 0


HURRAH! THATS IT! SAVE YOUR GAME!
_______________________________

Unessential Stuff

Actually, theres a bit more. This is not essential. Say you had an RPG movement, and you only wanted a player to go through a door if he only had a key...this bits easy, you just need to make some modifications to the movement.

Ok, so, create a door 32x32 Pixels. It needs to be an Active Object...call it "DOOR". So far, the events Ive taught you only work if the player overlaps a backdrop. So, remember your NEGATE command, you'll need it here.

Go back through your events until you find...

REPEAT WHILE PLAYER MOVES UP
ALTERABLE VALUE A OF PLAYER = 0
ALTERABLE VALUE B OF PLAYER = 0
X UP IS OVERLAPPING BACKDROP

All you do is create one further event to that list...

REPEAT WHILE PLAYER MOVES UP
ALTERABLE VALUE A OF PLAYER = 0
ALTERABLE VALUE B OF PLAYER = 0
X UP IS OVERLAPPING BACKDROP
X UP IS OVERLAPPING DOOR

This event now stops the player from going through an active object, in this case, a door. It only works if he heads UP, mind, he can still walk left, right or down through the door. Find the other events and modify them like I just did to create a perfect, solid, door.

Thats it, hope you liked this (long) tutorial.