-1

While making a game, I had set it up so when the player dies, the game resets. Feeling this was a bit too harsh, I did some research and found the room_restart() code, which is meant to restart the current room. But, when I input it and triggered it via dying, it did not reset the room to how it was. How do I reset it?

{

room_restart()

}

That is the code that triggers on collision with an enemy.

The Man
  • 149
  • 3
  • 14
  • To be clear, are you using this? https://www.yoyogames.com/studio or a different environment? – Ian M May 07 '15 at 17:03
  • @IanM I am using the Game Maker: Standard Edition, which I belive is what you said. Incase you need it, the version is v1.4.1567. – The Man May 07 '15 at 17:05
  • 3
    You used persistent objects/rooms? – Dmi7ry May 07 '15 at 17:25
  • @Dmi7ry That seemed to be the case. The first level's room was set to persistent for some reason, while all of the others were not. It is working now. – The Man May 07 '15 at 17:28

3 Answers3

0

You would have to record the state somehow. Game Maker has a native state save function, but if you wanted a room to stay the same without changing the player's inventory or something, you'd have to manually record the state of every object in it so when the player leaves and comes back, everything resumes where it was.

You could try having each object record important variables to a file with sections for each room. For instance, you could use a JSON file with sections for each room, and each object would record their vital data into that section. For example:

{
  "rmHouse": {
    "Mom": {
      "x": 64,
      "y": 128,
      "action": "lookingDown"
    }
  }
}

Check around for Game Maker JSON extensions. Here's one for GM8.1/Studio: http://gmc.yoyogames.com/index.php?showtopic=565659

Kelvin Shadewing
  • 303
  • 2
  • 16
0

room_goto(room);

That will send the room back to how it was when you first entered it, but room_restart should do the same.

Make sure that you do not have "persistent" checked in the room options. That's what sounds like it's probably the issue to me.

0

If you had if(health = 0) { instance_destroy(); }, then delete instance_destroy. Replace it with x = 32 y = 64 health = max_hp restart_room(); so that the X position is set, the Y position is set, the health is back, and the room restarts.

Nizwiz
  • 1