Author Topic: Warping to more than one point in a room  (Read 1832 times)

Hop

  • Wannabe
  • Posts: 43
  • HopPros on Twitch
  • OS:
  • Mac OS X 10.9.5 Mac OS X 10.9.5
  • Browser:
  • Chrome 47.0.2526.80 Chrome 47.0.2526.80
    • View Profile
  • Playstyle: Keyboard
Warping to more than one point in a room
« 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.

lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 47.0.2526.80 Chrome 47.0.2526.80
    • View Profile
  • Playstyle: Keyboard
Re: Warping to more than one point in a room
« Reply #1 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.
(click to show/hide)

smoke weed everyday

Hop

  • Wannabe
  • Posts: 43
  • HopPros on Twitch
  • OS:
  • Mac OS X 10.9.5 Mac OS X 10.9.5
  • Browser:
  • Chrome 47.0.2526.106 Chrome 47.0.2526.106
    • View Profile
  • Playstyle: Keyboard
Re: Warping to more than one point in a room
« Reply #2 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.

Kyir

  • The Kid
  • Posts: 293
  • Normal Guy
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 47.0.2526.106 Chrome 47.0.2526.106
    • View Profile
  • Playstyle: Keyboard
Re: Warping to more than one point in a room
« Reply #3 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.
« Last Edit: December 23, 2015, 06:17:45 AM by Kyir »

lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 47.0.2526.80 Chrome 47.0.2526.80
    • View Profile
  • Playstyle: Keyboard
Re: Warping to more than one point in a room
« Reply #4 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.
(click to show/hide)

smoke weed everyday