Game Development Reference
In-Depth Information
When the player is found to be on slippery ground, he/she will slip uncontrollably in his/her current direction.
It is extremely important that you make sure that you toggle both the “Skip if cannot move” and “Wait for completion”
check boxes. If the former is untoggled, the game will hang as soon as the player reaches an obstacle. If the latter is
untoggled, the event will not work. (Give it a try and note how the character moves on the icy terrain.) Next, I assign a
new pair of variables to store the player's current x and y coordinates after moving one space. Why? Well, recall the last
bullet point in the summary list at the start of the chapter. We need to check to see if the player has been stopped by
an obstacle.
We can figure that out by comparing the values of X' and Y' with the values of X and Y. The only time X' and X
(and Y' and Y) will be identical is when the player is stationary. How can I guarantee this? It all comes down to the
event flow. At the very top of the event, we write the player's location to X and Y. After moving a single space (or failing
to, if the character is already adjacent to an obstacle), we write his/her location to X' and Y.
We escape the loop if the values of X' and Y' are equal to the values of X and Y; otherwise, we loop back to the top
of the sequence.
A Note About Redundant Code
As it turns out, you may have already noticed that we don't actually require that Loop command. That's something
really important to learn in programming in general and RMVXA specifically: Don't do in ten lines what you can do in
nine or fewer . In other words, make your events as efficient as possible. As you gain proficiency with RMVXA, you'll
probably find cases in which you created an event that has some fat that can be trimmed with no negative effects.
In this case, the Loop command doesn't take anything away from the slippery floor event, but you can use labels to
achieve the same effect.
Eventing Our Sliding Puzzle (continued)
Here's the last part of the slippery floor event:
@>
: Branch End
@>Label: GoToNext
@>Conditional Branch: Switch [0026:WalkMovement] == OFF
@>Set Move Route: Player (Skip, Wait)
: : $>Walking Animation ON
: : $>Change Speed: 4
: : $>Change Freq: 3
@>Control Switches: [0026:WalkMovement] = ON
@>
: Branch End
@>
This is where we go if the player is stationary from having bumped into an obstacle. We check to make sure
that WalkMovement is off and restore the player character's walking animation and set its speed back to 4. We set
WalkMovement to ON and we're all set. Of course, the event still isn't as clean as it could be. Think hard on what the
event is doing, and see if you can trim it down some more.
Creating the Icy Area
Of course, we've gone through all the trouble of creating this event. It wouldn't be proper to just have it there doing
nothing. Hence, let's make a little ice maze. You can already see it in a zoomed-out state in the full-map screenshot,
but Figure 11-2 shows a zoomed-in picture of the relevant area.
 
Search WWH ::




Custom Search