|
Post by barkera0 on Dec 17, 2004 18:08:24 GMT -5
What is an easy way to move from one room to another in an RPG? I have tried using an object so that when you collide with it you go to another room, but this uses way to many objects. Is there another way that uses less objects?
|
|
|
Post by IsmAvatar on Dec 17, 2004 18:44:40 GMT -5
when you place an object in a room, you can give it creation code right there. It's a different creation code than normal creation code. This is instance-specific creation code, as opposed to the entity-generic creation code. Ctrl+RightClick and click Creation Code to modify this. In here, for doors, I normally have a variable, like myroom, and set it to the room that it leads to. Then, on collision, go to the room of the variable.
|
|
|
Post by barkera0 on Dec 21, 2004 0:56:51 GMT -5
Sorry but I'm a bit confused! What do you mean?
|
|
|
Post by IsmAvatar on Dec 21, 2004 14:49:35 GMT -5
what part are you confused about.
|
|
|
Post by barkera0 on Dec 21, 2004 16:13:45 GMT -5
How does the variable help with the room changing?
|
|
|
Post by IsmAvatar on Dec 21, 2004 16:50:40 GMT -5
let's say you have 2 doors. One to the left, and one to the right. They are both the same object. In their Ctrl+RightClick Creation Code, they have
myroom = rm_leftdoor and the other has myroom = rm_rightdoor
and in the collision event with the player: room_goto(myroom)
this way, if you hit the left door, you go to rm_leftdoor, and if you hit the right door, you go to rm_rightdoor (or vice versa, if you gave them the wrong creation codes, lol.)
|
|
|
Post by Stenny on Feb 27, 2005 5:18:33 GMT -5
I have done this a lottof times (cuz I love playing and making RPG'S)...
It's a little system I created by myself, called goto's
you were right with the object collision thing, but you don't need much objects, in fact...only one... you just need to check the room, it's x and it's y, in the collision event......In this way, you can make hundred transitions with only one object
|
|
|
Post by stenny on Feb 27, 2005 5:22:36 GMT -5
or just chekc it's ID
|
|
|
Post by Ian on Mar 5, 2005 15:49:29 GMT -5
I just started making my own mini RPG and this has solved my one major problem so far, thanks guys.
|
|
Ian
Newbie
Posts: 3
|
Post by Ian on Mar 5, 2005 17:30:15 GMT -5
Wait, seems to be a problem, I've set the variable myid = room2 in the creation code but the game areas saying there is a missing variable. Any help?
|
|
|
Post by Nailog on Mar 5, 2005 18:02:47 GMT -5
Is that line of code in the CTRL-Right click Creation code of your room transition object? Are you using the myid variable in the collision event? Is this collision event on the player object, or the room transition object? Did you double-check and make sure there aren't any typos?
|
|
Ian
Newbie
Posts: 3
|
Post by Ian on Mar 6, 2005 4:11:32 GMT -5
Woo, fixed, I managed to overlap some objects on top of each other and the objet that the char was hitting wasn't the one with the creation code.
Now, when the char goes to the next room, he starts at the same co-ordinates as he was in the last room, is there a way to make him go to the opposite side of the room.
|
|
|
Post by Nailog on Mar 6, 2005 10:21:00 GMT -5
You'll have to use a couple more variables.
Perhaps a destination_x and a destination_y. When the collision occurs, copy these two to global variables.
In the room's Creation Code, check these two global variables and adjust the player object's x and y to match.
This most likely won't work if you use persistent rooms. However, the biggest benefit of persistent rooms is having the player object remain at its last position, so adding code like this eliminates the need for persistent rooms.
Edit: What I do is add a second object into the mix. I call it a waypoint, give it no events at all, and place it where I want a certain room transition to end up. In the waypoint's Creation code, I add something like ...
self.tag = "from midgar exit";
Instead of using x and y targetting variables in the room transition object, I place the destination tag, matching the waypoint's tag. This string is copied to a global variable on collision, and in the room creation code I do something like ...
with (obj_waypoint) { if (global.dest_tag == self.tag) { player.x = self.x; player.y = self.y; break; } }
(Indentation isn't carried over in code blocks. That certainly sucks.)
|
|
Ian
Newbie
Posts: 3
|
Post by Ian on Mar 7, 2005 5:46:11 GMT -5
Cheers Nailog, I'll try that out and tell you how it goes.
|
|
|
Post by weckar on Mar 13, 2005 6:55:15 GMT -5
in my opinion, store 3 variables: the room that it refers to, the x that it refers to and the y it refers to. (and for those 3d freaks out there also the z)
|
|