How do i make a door so i can get into another room?

Started by tomloadsadosh, Sun 30/11/2008 13:06:34

Previous topic - Next topic

tomloadsadosh

Ive looked through all the tutorial and i cant find out how can someone tell me plz.

Akatosh

I believe you're looking for the elusive ChangeRoom command.

Shane 'ProgZmax' Stevens

#2
Or if you mean a door that the player can click on to open/shut, you'll need to do at least two frames for the door (one opened, one closed) and then make it an object with a separate view that has two loops (one with the closed frame, one with the open frame).  When the player clicks on the door you would do a check to see which loop the door was currently on and then set it to the opposite, like so:
Code: ags

//assume that loop 0 of view DOORANIM is the closed door sprite and loop 1 is the door open sprite.  In this situation, oDoor is the name of the door object in question.

//also assume that you are using the interact cursor mode on the door, and this code would be located in the interact section of the door object script

if(oDoor.Loop==0) //if the door is closed, open it
{
   //set the object's view to DOORANIM, loop to 1, and frame to 0
  //Object.SetView(int view, optional int loop, optional int frame)
   
   oDoor.SetView(DOORANIM,1,0);

   //optional 1.  Set the baseline height of the door low enough that the player will always
  //appear in front of it when it is open.  You may want to set this high if the door needs to
  //appear in front of the player instead.

  oDoor.Baseline=1;  //player will always appear in front of the door when it's open.

   //optional 2.  This is if you want to create a walkable area around the door that can be turned
  //off and on to prevent the player from moving through the door.  Setting the object to solid
  //doesn't always work right, so this is the safe way to prevent movement through the door.
   RestoreWalkableArea(1);
}
else  //close the door
{
  
   //set the object's view to DOORANIM, loop to 0, frame to 0

   oDoor.SetView(DOORANIM,0,0);

  //optional 1.
  oDoor.Baseline=0;  //restores the door baseline to default.  May need manual setting.

  //optional 2.
 RemoveWalkableArea(1);
}


So to summarize, you'll need to name your object oDoor, the view it uses for animations DOORANIM, and loops 0 and 1 of that view for the door closed and open frames, respectively, for this to work.  Optionally, you can take the first walkable area and paint it in an area around the door to prevent players from going through it unless it is opened (you will have to initially remove the walkable area in the room script if the door starts off being closed).  Baselines are useful here so the player doesn't appear inside a closed door.

One more thing about walkable areas:  They are restored every time you leave and re-enter a room, so in the room's enter before fade in function you will have to check every door to see what it's loop is, and if it is a 0 (closed) you will need to remove the walkable area around it.  It can be a pain but the effect makes it worth it.

tomloadsadosh

Can someone please tell me how to make a door which leads to another room.

Dualnames

Well, either A)paint it with your background or B)make an object

A) Create a hotspot drawing over the door and create an interact interaction using
NewRoomEx(roomnumner,coordx,coordy);

B) Create an object, create a door animation assigning into a view and on the object door interact do this:

odoor.SetView(DOOROPEN);
odoor.Animate(0,5,eBlock,eForwards)//not sure about the parameters check the manual.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk