Doors between rooms

Started by Alen101, Fri 26/02/2016 16:38:05

Previous topic - Next topic

Alen101

Hi, im having a problem with my game maybe someone knows what to do in this case:

I have 3 characters, Player can change between characters anytime he wants.
So this is the problem:


MAP: side view:
roomA    roomB
(____2_)(_1____)
*() <-this are doors. doors are all closed.
*number 1 and 2 are characters

then:
*1 is in room B
*1 opens the door in order to go to room A
*player change character to character 2
*from room A the door linking the two rooms remains closed :(

since those are separated rooms i dont know what to do.
Is there a simple way to link doors in some way?
thats my problem, any help with this would be great!
thanks


The method i use to have doors opened or closed is :

when the door opens i put an object with the image of a opened door, and allow the character to change to room A


Crimson Wizard

Create a global variable, defining current state of the door, for each door.
Create an event handling function for the event "Enter room before fade-in", for each room that has door. These functions will run any time player enters the room, but before room becomes visible.
In that function check corresponding global variables and change object graphics.

Vincent

Even if it's just been told by Crimson Wizard.

Global Variables :
The Global Variables pane allows you to easily add variables to your game which can then be accessed from all your scripts.

// for room A
bool door_on_the_left_side_A_open // initial value false
bool door_on_the_right_side_A_open // initial value false

// for room B
bool door_on_the_left_side_B_open // initial value false
bool door_on_the_right_side_B_open // initial value false


You could do something like this for example...

// room script (B)
Code: ags

function hLeftDoor_WalkOn() // hotspot open left side door
{
   if (!door_on_the_left_side_B_open) // if the door is closed
   {
      door_on_the_left_side_B_open = true
      player.ChangeRoom(2); // room A
   }

   else // the door is open
   {
       
   }
}


function room_Load()
{
   if (player.PreviousRoom == 2) // room A
   {
      door_on_the_right_side_A_open = false; 
      door_on_the_left_side_B_open = true

      oDoor_left_side_B.Graphic = OPEN_DOOR_SPRITE;
   }
}


function room_AfterFadeIn()
{
   if (door_on_the_left_side_B_open)
   {
     player.Walk(/*x*/, /*y*/, eBlock, eWalkableAreas);
     cCharacter1.SetAsPlayer();
   }
}




// room script (A)
Code: ags

function room_Load()
{
   if (player.PreviousRoom == 1) // from room B
   {
      door_on_the_left_side_B_open = false; 
      door_on_the_right_side_A_open = true; 

      oDoor_right_side_A.Graphic = OPEN_DOOR_SPRITE;
   }
}


function room_AfterFadeIn()
{
   if (door_on_the_right_side_A_open)
   {
     player.Walk(/*x*/, /*y*/, eBlock, eWalkableAreas);
     cCharacter2.SetAsPlayer();
   }
}

SMF spam blocked by CleanTalk