Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[TUT] Edges as Exits using one event

Mea

Member

(note: if someone has a better term for this, please let me know and I'll change the header)

This is a simple event tutorial to help with making exits for wide open spaces acessable from a world map (example: forests, plains, etc.), among other uses. It removes the need to put dozens of events along the edge of the map. I hope it's easy to understand, it's my first tutorial.

Download Tutorial Project file (includes walkthrough game)


You need to have a basic understanding of Variables and the "Transfer Player" event.

Basic Transfers
First create two variables. Call them "TargetX" and "TargetY". These will be used to check where your character is on the map. X refers to the left-right location, while Y refers to the updown location.

Now to the map. We're going to pretend our map is 30 X 30.

When RMXP gets map coordinates, it starts with 0 instead of 1. This means our coordinates will range from 0,0 to 29,29. If your character is 5 squares to the right of the leftmost edge and 3 squares down from the top of the map, your coordinates would be "4,2".

Now we create a parallel process event to check for our location and to see if we're on the map's edge.
http://www.stkp.com/rpgmxp/tutorial/basic_edgeexits.jpg[/img]
We start by setting TargetX and TargetY to whatever our current coordinates are.

Next we use a conditional branch to see if we are on the top of the map (Is Y<=0). If it is, we ask if the player wants to leave the map. If they say yes, we transport them to the world map. If not, we have the player step away from the exit zone.

Then we do the same thing for the bottom of the map (Is Y>=29).

While it's not pictured, we do the same thing for the X values as well. Same principle, just with left and right.

And that's all there is to it.


Room to Room Transfers

This effect is good for puzzles or a more retro-feeling game where you go from screen to screen. I'm only going to do one edge for this example. What we're doing is transfering the character from area to area while keeping track of their position so that it looks like they're walking from room to room.

We need to create three more variables. MapX, MapY, and MapMap. These will be the variables we use when we use the Transfer Player option.

We're going to pretend our maps are 20 X 15, default size.

Once again, we create a parallel process event to check for our location and to see if we're on the map's edge.
http://www.stkp.com/rpgmxp/tutorial/roo ... eexits.jpg[/img]
We're only checking the leftmost edge of the map this time.

Again we start by setting TargetX and TargetY to whatever our current coordinates are. Then we check to see if the player is touching the leftmost edge.

Since we know our maps is 20 squares wide, and that the squares on x coordinate 19 are going to be used as our exit, we are going to want to transfer our character to the new map as far right as possible without triggering the exit. That means we send them to X coordinate 18; hence MapX=18

We want our character to be at the same up and down position when we cross the edge, so we make sure that MapY = our current Y coordinate.

And finally, the room next door is mapped on Map #5, so we set MapMap = 5

Now that we have our coordinates, we transfer the character to the next rooom. Use the same principles in the next room to make a way back.

And that's it. Hope it was helpful. :D
 
Not bad. This seems like an easier way then adding all those exits. This could probably be done better with a script. The one I've been using now though teleports me in bad spots. For example if I go to the up on one of the wrong tiles, I may end up in water in the next map that I get teleported to.
 

Mea

Member

True it probably could be done with scripts, but unfortunately like many board members, I don't know scripting, so I did this with events. And it works pretty well - haven't had any teleport errors like the one you described.
 
That was a lot of help, thanks, although I put in a conditional branch to determine which way a character is facing to verify the transfer.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top