GameMaker Lives drop to 0 but game over never happens

IceTray

Member
Hello, I am very new to game making. I started following a youtube tutorial called "My First Game" to learn how to make a basic space shooter game in drag and drop. I have a ship and when it crashes into the asteroids it loses a life but when my lives are at zero the game over screen never pops up. The game over screen is an object called obj_gameover that is supposed to be created whenever the lives are less or lower than zero. What obj_gameover actually does is just show text on the screen when it's created that says game over, shows a final score, and last you can press ESC to restart the game. I've been driving myself nuts trying to figure out why it won't pop up though. Any help would be incredibly appreciated.

This is when the ship object (player) crashes into an asteroid:


And this is how obj_game checks if it's a game over:
 

TsukaYuriko

☄️
Forum Staff
Moderator
Familiarize yourself with the Show Debug Message DnD.

Insert it at key points of your game logic (e.g. checking for lives, spawning the game over instance, any code that runs in the game over instance). Check which of these actually run. Maybe you'll notice that something that's supposed to run isn't actually running.

Alternatively: We have yet to see the code of obj_gameover, so I can't really tell whether that will work as you'd expect. You're creating it at 0,0, so without any further code, that's going to be created in the top-left corner of the room unless you explicitly specify otherwise.
 

IceTray

Member
I tried using the debug messages and everything seemed to be working fine. I made one for when I lost a life, when the lives pass zero and when the game over is supposed to be showing but still I'm seeing nothing. Here is everything that the obj_gameover does




 

TsukaYuriko

☄️
Forum Staff
Moderator
You're attempting to draw in the Create event.

You can't draw in the Create event*. That's what the Draw event is for.

* you technically can, but that will be overwritten by anything that is drawn after it, including the room background that covers the entire view.
 

FrostyCat

Redemption Seeker
It disturbs me how much effort novices put into learning actions and functions, and at the same time, how little effort they put into learning about events where the said actions and functions will belong.
 

IceTray

Member
You're attempting to draw in the Create event.

You can't draw in the Create event*. That's what the Draw event is for.

* you technically can, but that will be overwritten by anything that is drawn after it, including the room background that covers the entire view.
Thanks so much for the help, I really appreciate it! I moved that all to a draw event and it's working perfectly now.
 

IceTray

Member
I do have one last question though. How would I go about making the text stop being drawn? I've tried making it so when I press space to restart the level the obj_gameover gets destroyed but that doesn't seem to remove the text from the screen.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Making something stop to be drawn is the same as not drawing it anymore.

Similarly, making something stop existing despite being destroyed is the same as not spawning instances of it anymore.
 

IceTray

Member
Making something stop to be drawn is the same as not drawing it anymore.

Similarly, making something stop existing despite being destroyed is the same as not spawning instances of it anymore.
I took what you said into consideration and added an "if instance exists" variable so now instead of just drawing endless game overs once you lost your lives, now it only does it when obj_gameover doesn't exist already, so only once. Now I have a new issue though. When I press space to "try again" The game still thinks I have zero lives so it never closes the popup. even though when space is pressed the lives are supposed to be set back to 3.


 
Top