Fangames > Programming Questions

Warping to more than one point in a room

(1/1)

Hop:
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.

lawatson:
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.

Hop:
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.

Kyir:
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.

lawatson:
heh, i'm not familiar with the studio engine's way of handling variables. kyir's probably better in this situation.

Navigation

[0] Message Index

Go to full version