Question about multiple room entrances

Started by Bandersnatch, Tue 21/02/2012 04:34:09

Previous topic - Next topic

Bandersnatch

I am currently developing a tech demo for my first game and have hit a bit of a bump.

The demo has one central area with access to various other rooms. This isn't a problem, but when I return to the central room I want my character to walk on from the appropriate side of the screen and face in the appropriate direction. This is something I'm struggling with, as I can only seem to have them appear stock still in the central area facing the direction they were when leaving the previous room...

Ryan Timothy B

Check out Character.PreviousRoom in the manual.

Code: ags

function room_Load()
{  
  if (player.PreviousRoom == 2) 
  {
    player.X = 10;
    player.Y = 10;
    player.Loop = 2;
  }
}


With the above code it checks if the Player's previous room was room 2. Then it position it at 10,10 with Loop 2. Best done in Room Load because it moves the Player character to the appropriate spot before Fade In.

Fuchs

I managed a fairly similar problem this way:
I added several regions to the room, and then i used the sidefunction of retions "when walking onto region" then i typed into the script:


function region1_WalksOnto() //automatically created by AGS when you press on the "walk onto region"
{
cMausie.ChangeRoom(2, 1481, 536);
}


This way your character changes to room Nr. 2, and faces the x1481,y536 position. If you want him/her to walk to a certain point you could try the
cMausie.Walk(x,y) command, although i bed if you typed in the walk command the character faces automatically a certain direction, the direction he walked to.
Thats at least the way i would solve it.

Khris

Fuchs,
the .ChangeRoom command isn't executed until the function has finished, so putting a .Walk command below .ChangeRoom will still make the character walk first, then change rooms.
That's the reason why .PreviousRoom exists, to allow to work around this.

It's nice that you want to help, but please don't mislead other beginners with bad advice. At least test your method before posting it.

Bandersnatch

Thanks everybody, got it sorted now. As I'm so new to the whole AGS thing and am on the road to creating something way out of my depth, expect to hear more similarly inane and entry level questions.

Fuchs

To put it all in a nutshell, here the proper walk function:
For the Room #1, the Room your chara just entered:
Function room_afterFadeIn()
{
If (cMünchenspastSammyPreviousRoom == 2 ) {
cMünchenspast.Walk(160,160,eBlock,eWalkableAreas);
}
}
Don’t forget to adjust the starting points in the previous room #2

function_leaveRoomBottom()
{
cMünchenspast.ChangeRoom(1, x,y,);
}

Khris

Very mature, Fuchs, Münchenspast, really?

Where are all these idiots coming from all of a sudden? There's gotta be a nest somewhere.

SMF spam blocked by CleanTalk