|Making maps sloped for cycling|
|Click here for more tutorials!|
A Cycling Road has two main characteristics:
- It changes the movement speed depending on the players direction:
- DOWN -> fast
- UP -> slow (only GEN I-III)
- LEFT/RIGHT -> normal
- It forces the player to move down, unless the latter is manually moving into another direction or holding "B" (X on the Keyboard).
Determining whether the player is on a Cycling Road
Add the following def into a script section of your choice (for example PokemonUtilities):
def onCyclingRoad? maps=[20,21,22] for map in maps return true if map == $game_map.map_id end return false end
Change highlighted part to the map id(s) of your Cycling Road.
Changing the movement speed
Now we need to write a def which changes the movement speed accordingly. Add the following def right below the first one:
def bikespeed slow = $RPGVX ? 4.5: 3.8 normal = $RPGVX ? 8.0: 5.2 fast = $RPGVX ? 8.5: 5.4 if onCyclingRoad? dir= $game_player.direction if dir==2 move_speed = fast elsif dir==8 move_speed = slow else move_speed = normal end else move_speed = normal end return move_speed end
Also, in the script section "Walk_Run", change the highlighted line:
if $PokemonGlobal.bicycle @move_speed = bikespeed
You can modify the given speeds in "bikespeed" as you wish.
If you want to imitate GEN IV games, you might want to remove the speed reduction while moving up and put "normal" instead of "slow" at the line in question.
Note that the red value concerns RPG MAKER VX, while the blue value concerns RPG MAKER XP.
Forcing the player to move down
Next, we need to force the player to move down. This can be achieved by adding the yellow piece of code to the def "update" in the script section "Game_Player":
dir=Input.dir4 # force down if on CYCLINGROAD if onCyclingRoad? dir=2 if dir==0 && !Input.press?(Input::B) #[X] holds position end