Gw Temp

Menu

Tutorial - 'Inverse 8-Dir Movement for Events' by mooglemaster

An item about RPGMaker 2000 posted on

Blurb

mooglemaster's excellent new tutorial about inverse eight-directional movement for an event. Check it out!

Body

If your question is whether all my tuts come from my games, well... let's say past ones and some to come will be from them. All my complex coordinate tutorials come in part of creating an easy adaptation to my Real Time Strategy Game: Age of Game Makers I. And that's just the title, there won't be an AoGM II.

So what am I planning to mess you up with? You guessed it, inverse 8-directional movement for an event. So basically what I refer to as an 8-directional movement for an event is having an event go to a place using 8 directions. Then, the inverse of this would be for example having an event go from Point A to B through Trail C, and going back from Point B to A through Trail C again. If it wouldn't be inverse movement the event would go through Trail D, not Trail C. And it is not as easy as it sounds.

STEP 0 - VARIABLES

Variable 0001 - Event X
Variable 0002 - Event Y
Variable 0003 - Event X Difference
Variable 0004 - Event Y Difference
Variable 0005 - Destination X
Variable 0006 - Destination Y

Not much is needed, and I think the variables are self-explanatory.

Create an event with a Parallel Process.

<>Change Variable: Var[0001:Event X] = Event's X Pos
<>Change Variable: Var[0002:Event Y] = Event's Y Pos
<>Change Variable: Var[0005:Dest X] = Destination's X Pos
<>Change Variable: Var[0006:Dest Y] = Destination's Y Pos
<>Change Variable: Var[0003:Event X Dif] = Var[0001]
<>Change Variable: Var[0004:Event Y Dif] = Var[0002]
<>Change Variable: Var[0003:Event X Dif] - Var[0005]
<>Change Variable: Var[0004:Event Y Dif] - Var[0006]
<>If Var[0003:Event X Dif] 0 (<)
<>Change Variable: Var[0003:Event X Dif] * -1
<>
:End Case
<>If Var[0004:Event Y Dif] 0 (<)
<>Change Variable: Var[0004:Event Y Dif] * -1
<>
:End Case
<>

Most of the code is self-explanatory but with the differences I used a theorem for distance to convert the variables into positive numbers given to fact that the variables might become negative.

**PHYSICS CLASS - A distance will always be equal or greater than zero**

STEP 2 - FOUR DIRECTIONAL MOVEMENT

<>If Var[0005:Dest X] Var[0001:Event X] (=)
<>If Var[0006:Dest Y] Var[0002:Event Y] (>)
<>Move Event: Event Down
<>
:End Case
<>
:End Case
<>If Var[0005:Dest X] Var[0001:Event X] (=)
<>If Var[0006:Dest Y] Var[0002:Event Y] (<)
<>Move Event: Event Up
<>
:End Case
<>
:End Case
<>If Var[0005:Dest X] Var[0001:Event X] (>)
<>If Var[0006:Dest Y] Var[0002:Event Y] (=)
<>Move Event: Event Right
<>
:End Case
<>
:End Case
<>If Var[0005:Dest X] Var[0001:Event X] (<)
<>If Var[0006:Dest Y] Var[0002:Event Y] (=)
<>Move Event: Event Left
<>
:End Case
<>
:End Case
<>

In short:

STEP 3 - EIGHT DIRECTIONAL MOVEMENT

<>If Var[0005:Dest X] Var[0001:Event X] (>)
<>If Var[0006:Dest Y] Var[0002:Event Y] (>)
<>If Var[0003:Event X Dif] Var[0004] (=)
<>Move Event: Event Right/Down
<>
:Else Case
<>If Var[0003:Event X Dif] Var[0004] (>)
<>Move Event: Event Right
<>
:End Case
<>If Var[0003:Event X Dif] Var[0004] (<)
<>Move Event: Event Down
<>
:End Case
<>
:End Case <>
:End Case
<>
:End Case
<>If Var[0005:Dest X] Var[0001:Event X] (>)
<>If Var[0006:Dest Y] Var[0002:Event Y] (<)
<>If Var[0003:Event X Dif] Var[0004] (=)
<>Move Event: Event Right/Up
<>
:Else Case
<>If Var[0003:Event X Dif] Var[0004] (>)
<>Move Event: Event Right
<>
:End Case
<>If Var[0003:Event X Dif] Var[0004] (<)
<>Move Event: Event Up
<>
:End Case
<>
:End Case
<>
:End Case
<>
:End Case
<>If Var[0005:Dest X] Var[0001:Event X] (<)
<>If Var[0006:Dest Y] Var[0002:Event Y] (>)
<>If Var[0003:Event X Dif] Var[0004] (=)
<>Move Event: Event Left/Down
<>
:Else Case
<>If Var[0003:Event X Dif] Var[0004] (>)
<>Move Event: Event Left
<>
:End Case
<>If Var[0003:Event X Dif] Var[0004] (<)
<>Move Event: Event Down
<>
:End Case
<>
:End Case
<>
:End Case
<>
:End Case
<>If Var[0005:Dest X] Var[0001:Event X] (<)
<>If Var[0006:Dest Y] Var[0002:Event Y] (<)
<>If Var[0003:Event X Dif] Var[0004] (=)
<>Move Event: Event Left/Up
<>
:Else Case
<>If Var[0003:Event X Dif] Var[0004] (>)
<>Move Event: Event Left
<>
:End Case
<>If Var[0003:Event X Dif] Var[0004] (<)
<>Move Event: Event Up
<>
:End Case
<>
:End Case
<>
:End Case
<>
:End Case
<>Wait Until Moved
<>

And that's where coding ends. It basically checks if both differences are equal so it can move diagonally. If they're not it will check which difference is bigger. If the X Dif is bigger it will go Left or Right. If the Y Dif is bigger it will go Up or Down. Chibi.

Comments - If you just went directly down here, or didn't understood on the top, what this does is that it makes and event move to a direction in an 8-Directional way; but instead of moving first diagonally it first moves horizontally and vertically. Very chibi.

PS - Hey Nick!