In the last Part we finally made a generated Map, but there’s still one thing missing: Once on the Map, we cannot continue our journey.
On the Space Map, place an Event and make it parallel process. This Event checks if the Player touches the Map’s border and will then transfer him to the next stage. That can be a new randomized or an ordinary Map.
We check whether the player has reached the outline of the map by regularly querying his position and comparing it with the size of the map. In our example, having a road from south to north, we only need to check the Player’s Y coordinate, however, if you have a map with exits to any other directions, you will need to check them aswell.
- Using Variable Operation we store the Player’s X and/or Y coordinate
- Make a Conditional Branch
- To check if the Player has reached north or west is simple. Just check if his X or Y coordinate is < 1.
- To check if the Player has reached south or east, you can insert a Script Call in the Condition Branch (Tab 4) and paste this:
$gamePlayer.x + 1 == $gameMap.width()
$gamePlayer.y + 1 == $gameMap.height()
- Inside the Branch, you can do some calculations to determine where the Player will be transferred. For instance, you can add a „progression counter“, that adds 1 until the Player reached the required level to escape from the dungeon.
If you want to generate a new random Map, just call the Common Event.
If you want the Player to escape from the Dungeon, just transfer him to any other Map.