Maximize MenuMinimize Menu

 

 

Back | Home

Walking Character Game-Editor Tutorial

Let's create a walking character. One that will follow the arrow keys on the PC and the 4 way button on the Pocket PC. Start by first downloading one of Reiner "Tiles" Prokein's fantastic freeware sprites. All he asks for is a credit if you use his graphics: http://www.reinerstileset.de Reiner has some great tile artwork also for backgrounds, buildings, paths, all sorts of goodies.

OK here we go!

1)Add Actor and Artwork

Add an actor "mainChar" to a Game Editor session.

Add an animation "MainCharN' and add the file "walking n0000.bmp" as a multiple file.

Add an animation "MainCharE' and add the file "walking e0000.bmp" as a multiple file.

Add an animation "MainCharS' and add the file "walking s0000.bmp" as a multiple file.

Add an animation "MainCharW' and add the file "walking w0000.bmp" as a multiple file.

Note: You can change the starting animation by using Actor Control and the animation pull-down. Let's start with MainCharN.

2) Add Key Down/Up Events
Let's add our key down/up events now.

Add Event Key-down press the up arrow add the event Change Animation, use:

Event Actor
MainCharN
No change

Add as immediate action

Add Event Key-down press the left arrow add the event Change Animation, use:

Event Actor
MainCharW
No change

Add as immediate action

Add Event Key-down press the down arrow add the event Change Animation, use:

Event Actor
MainCharS
No change

Add as immediate action

Add Event Key-down press the right arrow add the event Change Animation, use:

Event Actor
MainCharE
No change

Add as immediate action

Now test your sprite in Game Mode by making sure he switches directions as you select the different arrow keys.

 

3) Add Movement Factors
Now let's make him move!!!
We will increment/decrement our actors screen coordinates through button presses. I have chosen 3 pixels as a distance traveled, feel free to adjust that. I use the actor's name and his x/yscreen coord but you can also just use "x -= 3" for example.

What is this funny looking "x -= 3;" or "x += 3;" you ask??? it's just C language shorthand for saying "x = x - 3" or "x = x + 3" -I started using it and now I am hooked.

Here we go!

Actor Control
Events Add Key Down
Press the left arrow
Add Action
Script Editor
mainChar.xscreen -= 3;

Actor Control
Events Add Key Down
Press the right arrow
Add Action
Script Editor
mainChar.xscreen += 3;


Actor Control
Events Add Key Down
Press the down arrow
Add Action
Script Editor
mainChar.yscreen += 3;

Actor Control
Events Add Key Down
Press the up arrow
Add Action
Script Editor
mainChar.yscreen -= 3;

 

4)Stop Walking Motion When Stationary
One final detail and we will be done...

Our sprite keeps walking even when he is standing still. What we need to do is stop the animation when we release an arrow key, we also need to start the animation back up when we depress an arrow key.

We need to use "Change Animation Direction" Forward and Stopped.

For each direction add a Key Down and a Key Up event:

The key Down event will be:
Change animation direction
Event Actor
Forward

The Key Up event will be:
Change Animation Direction
Event Actor
Stopped


ALL DONE!!!
Now walk your guy around, make a game out of it!!!

 

 

Radiosity Games
See our new game site

 

 

 

©Copyright TrajectoryLabs.com. All Rights Reserved.