Gw Temp


Tutorial - 'Hero Movement' by Awesome

An item about RPGMaker 2000 posted on


How to make the hero face a direction when key is tapped, and walk in that direction when its held down.


In rm2k, when you tell the hero to move in a direction, he moves one pixel up that way. But what if you just wanted him to face that direction, instead of moving there? Well, this tutorial came about after some questions on the forums, seeing as I didnt have any tutorial ideas, this was good.
I tried this in a test game, and I got it working.... fairly well :P Read on for more info.

What will be used in this tutorial:
Enter Password, Forks and Variables.

First of all, we make a common event, or if your just using this for one map, an event off to the side will do. Eitherway, they have to be parrallel proccess, event starting conditions are your choice, and arent necessery.

Basically to start off we have to check what key is being hit. We do this by using a enter password command which is stored into a variable.

<>Enter Password: Var[0001:Key]

Uncheck everything except Direction (This includes wait until key hit)
This just enters what key you pressed into that variable, this can be any variable I named mine key.
Just for refrence: Down Arrow = 1, Left = 2, Right = 3, Up = 4, Action Key (Space) = 5, Cancel (Esc,x) = 6.

<>If Var[0001:Key]-1
Move Event Hero-Wait
Wait 0.1 Sec

No else case for this fork.
This checks that the Down Arrow was hit. And stops the hero from moving. If the hero-wait wasnt there, he would move because as default the command to move down was given when you pressed the down arrow.
You also wait for 0.1 secs to make check if its being tapped or held down. (You may want to change the wait command if its not responsive enough, however I found that over 0.2secs is far too laggy and jerky, even 0.2 is bad if you plan to use this for the whole game. I had no problems with 0.1secs, you just have to be fairly quick ;))

EnterPassword: Var[0001:Key]
<>If Var[0001:Key]-1
<>Move Event: Hero-Down
<>Move All

Make an else case for this fork.
Ok, now we check that the key is still being held down after 0.2 secs. If it is, we take this as its being held down, and the hero is moved down, as per usual.
The Move All, helps lag, and doesnt make the character jerky when moving. For the Move Event: Hero-Down remember to check the Ignore if cant be moved. This is very improtant, or as soon as
your hero tries to make in an area thats set as unpassable the game will stop working.

:Else Case
<>Move Event: Hero-Face Down
<>Move All
:End Case

Ok, if the key wasnt held down - which means it was tapped - the hero is turned to face down.
The Move All helps eliminate lag..

Now, we just repeat this for every other key.
Use the guide above to help you with what the numbers are.
I'll make moving left for you here:

If Var[0001:Key]=2
<>Move Event: Hero-Wait
<>Wait: 0.1 Sec
<>Enter Password: Var[0001:Key]
<>If Var[0001:Key]=2
<>Move Event: Hero-Left
<>Move All
:Else Case
<>Move Event: Hero-Face Left
<> Move All
:End Case
:End Case

I think you can figure out the other 2 keys.

Possible Changes:
Well, basically this shows you how to make the program recognise key taps, and the key being held down. You can change all the outcomes, (move events) into anything. It can be that the hero jumps when the key is tapped and moves normally when held down. Maybe you can use this in an ABS, if its held down for 0.1 sec he does a weak move, however if for 1 second its more powerfull. There are lots of possibilities, and this isnt limited to just this.
You can also change the wait commands, they dont have to be 0.1 secs, I just found this works best for me. It might be different for you.
Also, keep in mind wait 0.0 secs really means wait 0.03 secs.

Known problems:
Might not work well with other parallel events, especially lots of them, at once, or other enter password commands. I havnt tried this, but this is what I think from the coding.
Also, the 0.1 second wait might be too short for some people.

Other then this, just experiment with the code to find a good combination.
This is the best I could come up with :P

I will probablly put up a sample game on my website - - however no guarrantees on when that'll be.

Hope this helps someone :)