I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: Hop on December 19, 2015, 01:55:26 AM

Title: Warping to more than one point in a room
Post by: Hop on December 19, 2015, 01:55:26 AM
So I want to have two different places that you can warp to in the same room. For example I have the initial starting spot that you warp to when you get to a new screen and then halfway through you find a secret which takes you to the secret screen. Then once you beat the secret screen I want it to warp you back to where you got the secret rather than having to start the room over again to avoid players being frustrated.

How do I do this? The only solution I could think of was to make an identical room that has the starting point where I want it to be so players think its the same room, but that seems bad and would clutter things.
Title: Re: Warping to more than one point in a room
Post by: lawatson on December 19, 2015, 02:06:51 AM
make a global variable when warping the player back to that room, for example:

global.warpfromsecret[secret id]=1;

in some random object (maybe the warp), just put this in the create event:

if global.warpfromsecret[secret id]=1{
    player.x=teleportX;
    player.y=teleportY;
    global.warpfromsecret[secret id]=0;
}

i hope it works.
Title: Re: Warping to more than one point in a room
Post by: Hop on December 22, 2015, 10:31:54 PM
Hey thanks for the reply!

I think I must be implementing it wrong though cause the game error messages every time I hit the portal. I'm using Yoyo's engine for studio if that makes a difference. I tried putting the code in several different places and none of them worked.
Title: Re: Warping to more than one point in a room
Post by: Kyir on December 22, 2015, 11:40:54 PM
It would probably be easier to just make a unique object for warping in this situation. Just call it warp2 or whatever.

I'd make DestRoom, xx, yy, variables in the create event. Set them to whatever.

Collision with Player:
player.room = DestRoom
player.x = xx
player.y = yy

Then when you place them in the game set the creation code to where you want the player to go in each case. Anything else frankly seems like over-complicating it, unless I'm grossly misunderstanding the problem.
Title: Re: Warping to more than one point in a room
Post by: lawatson on December 23, 2015, 12:38:30 AM
heh, i'm not familiar with the studio engine's way of handling variables. kyir's probably better in this situation.