• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Using Checkpoints and lives at the same time

Liam Earles

Member
So I've been following Shaun's tutorial video on how to add checkpoints in the game and I did okay with it. But however, I'm having trouble with using checkpoints and lives at the same time. No matter what I do, the player would respawn (sometimes) to the checkpoint, and I would not be able to lose a life in the game. Before you comment on anything, I deleted almost every single code I learned from the tutorial video that's checkpoint related because I got so frustrated. So I just need some help figuring out how to use checkpoints and lives in the game so I can at least have a lives system in the game while also using checkpoints.
 
Let's just assume that we have no idea what is going on in Shaun's tutorials (well at least I certainly don't), please provide more information about your code..

How do you handle checkpoints in your game? do you use the built in save states? Do you write to a file? or maybe you just remember the location of the checkpoint and warp to it?
What do you mean by lives? is that just a number?

Generally, every information that you want the game to remember even after its closed should somehow be written to a file, and then read from it when you load your game.
 

Liam Earles

Member
Let's just assume that we have no idea what is going on in Shaun's tutorials (well at least I certainly don't), please provide more information about your code..

How do you handle checkpoints in your game? do you use the built in save states? Do you write to a file? or maybe you just remember the location of the checkpoint and warp to it?
What do you mean by lives? is that just a number?

Generally, every information that you want the game to remember even after its closed should somehow be written to a file, and then read from it when you load your game.
For the checkpoint I first used the drag and drop save game and load game buttons just naming the save file "CheckPoint" and loading up the checkpoint save file when the player in the game dies. I start out with 3 lives for the game and if I reached less than or equal to 0 lives in the game then it's game over. I did tried out the save game and load game features but I still won't lose a life in the game. So if I have 3 lives, and I fall into a pit, I don't lose 1 life. It would be back to 3.
 
For the checkpoint I first used the drag and drop save game and load game buttons just naming the save file "CheckPoint" and loading up the checkpoint save file when the player in the game dies. I start out with 3 lives for the game and if I reached less than or equal to 0 lives in the game then it's game over. I did tried out the save game and load game features but I still won't lose a life in the game. So if I have 3 lives, and I fall into a pit, I don't lose 1 life. It would be back to 3.
I'm not sure i understand, Do you load the game every time you fall into a pit? in that case if you had 3 lives and you reload you'll have 3 lives again.
 

TheouAegis

Member
DnD Save Game is just a save-state. It resets all your variables back to where they were at the time of the save. So make sure, if anything, you subtract the lives AFTER reloading the save state.
 
I personally would just save the x and y position of the checkpoints in a variable in the player.
Code:
//Player Create Event
lives = 3;
checkX = xstart;
checkY = ystart;
When the player interacts with a checkpoint(collision, higher x position, pressing a button etc...) run code like this
Code:
//Interact event of choice
other.checkX = x;
other.checkY = y;

instance_destroy();
Finally on death run this
Code:
//Player dies
if(lives>1){
   lives--;
   x = checkX;
   y = cehckY;
}else{
  //Gameover code
}
If you want to add saving your games project then you just write the checkX, checkY, and lives to a file or use the save state functions built in. If you aren't doing saves then you could just restart the room or go to a menu.
 
Last edited:
Top