Pressing F9 starts game in 2nd room (SOLVED)

Started by antineff, Thu 23/03/2006 13:19:43

Previous topic - Next topic

antineff

Hi,

I made an intro for my game. I made it by creating a seperate room with no player displayed. There is only an animated object and after the animation is finished the player is moved to the next room. Arriving in this room, two messages are displayed and after that I can start walking and playing. If I now press F9 the player position will be reset to the players starting position of this 2nd room. This means that the intro and the two messages are left out (BTW: The messages are in the first-time-player-enters-room-section of the second room).

Why does the game not start with the intro (the first room) again?
coming soon (or later, sorry!)

strazer

The default restart point is set after the first room is loaded and all blocking functions (your intro) have run.

As of AGS v2.72 Beta 3 this has changed:
* Changed the default restart point to be just before the first room is loaded, in order to avoid problems with the restart point not working properly in some games.

If you're not using v2.72 yet, you could try to not let the intro start right away but start it after a timer has expired:

Code: ags

// script for room: Player enters room (after fadein)
  SetTimer(1, 1000); // wait a second


Code: ags

// script for room: Repeatedly execute

  if (IsTimerExpired(1) == 1) { // after the second has expired
    // run intro here
  }

antineff

#2
Thank you, strazer, for the explanation. I now understand how this feature is working.

I also tried your suggestion, but unfortunately it doesn't work. The intro-run is completely ignored and I'm left on my first screen.


++++++++++++++++++++++++++++++++++++++

But I now tried something different, which makes me wonder , if your explanation was really correct.

Please take a look

Code: ags

  // script for Room: Player enters room (after fadein)

Wait(100);                                               // defering visibility of object[0] a bit
object[0].Visible = true;
Wait(1);                                                   // without that object.Visible won't work
DisplayAt(320, 240, 1, " ");                      // display nothing to wait for interaction

// start animation
object[0].SetView(16);
object[0].Animate(0, 3, eOnce, eBlock);  

DisplayAt(320, 240, 1, " ");                     // display nothing to wait for interaction
player.ChangeRoom(6, 310, 150);          // goto next room


Since I gave space and time for interaction, it doesn't lead to it, that the game restart point is in the first room (maybe after the first DisplayAt). It is still in the second room as describes.
coming soon (or later, sorry!)

strazer

Wait is a blocking function, I don't think that would work.

I remembered, the timer is set in number of game loops, not milliseconds, so 1000 game loops are 25 seconds, probably a bit much. Try changing
  SetTimer(1, 1000);
to
  SetTimer(1, 40); // one second

antineff

#4
Great experience!

That helped! It works! Thank you so much!

BTW:
I set the timer to 2 game loops and it is alright too. But did you try to set the timer to 1 game loop? That seems to be too short, since it gives me the old situation again. Seems that 1 is too less to count.
coming soon (or later, sorry!)

strazer

No, I chose 1 second (40 game loops at the default game speed) just to be on the safe side. Good to know it works with 2 game loops as well. Anyway, glad I could help. :)

SMF spam blocked by CleanTalk