Game Freezing

My game is is freezing when I die in a battle. The thing is, it is only certain enemies that he dies on. I'm wondering what conditions woujld cause a crash like that in GMS. An infinite loop? I haven't used any loops so it would have to be a with statement, right? But my code for that doesn't have any with statements.
 

chamaeleon

Member
My game is is freezing when I die in a battle. The thing is, it is only certain enemies that he dies on. I'm wondering what conditions woujld cause a crash like that in GMS. An infinite loop? I haven't used any loops so it would have to be a with statement, right? But my code for that doesn't have any with statements.
Start the program in debug mode and hit the break button to see where it is at that point in time.
 
Hey

When I have one character attack another character, they attack and it runs like usual then
everything freezes. Its just the GMS2 that freezes, my desktop and everything outside GMS
is fine. I haven't use for or while loops in my project and there is a with but there isn't a
with in a with.
 
Ha! That's the thing. There is no code.
Well no direct code. I commented all the code for the object and does the same thing. It fades a title screen in the lower left corner in then it switches to the full screen.
 

samspade

Member
If that were really true, you might as well scrap the project, or at least a portion of it, because there would be nothing you could do. But, nothing happens without code so there is code. The point of debugging is to figure out what code it is. If you're lucky you can just run it in the debugger and when it freezes hit the pause button. In most cases this will work and pause you inside of whatever place the game is stuck.

If that doesn't work, you just start removing or commenting out objects or scripts until the problem goes away, then you examine (or post here) the last portion of code removed.

Also, it seems very, very unlikely that you don't have a for, while, or do until loop. You can search pretty much your entire code base with control + shift + f. I would look for while and do until first. After that, look at the for looops - for loops that start at zero, increment by one, and terminate at a positive number are pretty safe, but everything else is suspect.
 
Last edited:
If that were really you true, you might as well scrap the project, or at least a portion of it, because there would be nothing you could do. But, nothing happens without code so there is code. The point of debugging is to figure out what code it is. If you're lucky you can just run it in the debugger and when it freezes hit the pause button. In most cases this will work and pause you inside of whatever place the game is stuck.

If that doesn't work, you just start removing or commenting out objects or scripts until the problem goes away, then you examine (or post here) the last portion of code removed.

Also, it seems very, very unlikely that you don't have a for, while, or do until loop. You can search pretty much your entire code base with control + shift + f. I would look for while and do until first. After that, look at the for looops - for loops that start at zero, increment by one, and terminate at a positive number are pretty safe, but everything else is suspect.
Excuse me, "if that were really true". Commented out all the code for the object. So there must be something else in another object. And I wrote the code and can assure you, there is no for, while, or do-loops. In fact I wrote my game using just with and
ifs So "scrap your project" is the best advice you can give me?
If that were really you true, you might as well scrap the project, or at least a portion of it, because there would be nothing you could do
Yeah ok. One character doesn't work so I'm going to scrap my whole project. That's ridiculous.
But, nothing happens without code so there is code. The point of debugging is to figure out what code it is. If you're lucky you can just run it in the debugger and when it freezes hit the pause button. In most cases this will work and pause you inside of whatever place the game is stuck.
IT doesn't freeze so I can't quite do that.


If that doesn't work, you just start removing or commenting out objects or scripts until the problem goes away, then you examine (or post here) the last portion of code removed.
Did that. That's how I found out none of the code for object was causing the problem. Listen. Its really simple. There is an icon a the top. You click on the icon and a bat flies down and when it lands it turns into a type of bat. Then you get to move him around and zap stuff with electricity.That's as simple as I can make it. What is going wrong is when I click on that icon and it drops the bat he lands. But immediately after that you see what you see in the picture attached. A corner cut of my game logo. After that it turs to full screen. Then goes to title screen and then game goes over again.

Also, it seems very, very unlikely that you don't have a for, while, or do until loop. You can search pretty much your entire code base with control + shift + f. I would look for while and do until first. After that, look at the for looops - for loops that start at zero, increment by one, and terminate at a positive number are pretty safe, but everything else is suspect.
Haha. Yeah technically I don't have a for or while loop. Break it down I don't need a for loop. a while loop does just fine. But lets do something simpler. A timer. I cheated. GMS has built in while loops because they have implemented loop events. Like step. Say you want to say this while loop code:

while { a++ }

just put a++ in the step event.
I challenge you to come up with a while construct that I can't come up with using a step event.

Actually I challenge you to figure out what in the **** is wrong with my program. You get a medal if you figure that.
And so the saga begins........
 

Attachments

samspade

Member
Excuse me, "if that were really true". Commented out all the code for the object. So there must be something else in another object. And I wrote the code and can assure you, there is no for, while, or do-loops. In fact I wrote my game using just with and
ifs So "scrap your project" is the best advice you can give me?
Yeah ok. One character doesn't work so I'm going to scrap my whole project. That's ridiculous.
IT doesn't freeze so I can't quite do that.


Did that. That's how I found out none of the code for object was causing the problem. Listen. Its really simple. There is an icon a the top. You click on the icon and a bat flies down and when it lands it turns into a type of bat. Then you get to move him around and zap stuff with electricity.That's as simple as I can make it. What is going wrong is when I click on that icon and it drops the bat he lands. But immediately after that you see what you see in the picture attached. A corner cut of my game logo. After that it turs to full screen. Then goes to title screen and then game goes over again.



Haha. Yeah technically I don't have a for or while loop. Break it down I don't need a for loop. a while loop does just fine. But lets do something simpler. A timer. I cheated. GMS has built in while loops because they have implemented loop events. Like step. Say you want to say this while loop code:

while { a++ }

just put a++ in the step event.
I challenge you to come up with a while construct that I can't come up with using a step event.

Actually I challenge you to figure out what in the **** is wrong with my program. You get a medal if you figure that.
And so the saga begins........
Sorry. I wasn't trying to be rude. I was merely pointing out that if you're saying you didn't write the code that caused the problem, then there is literally nothing you can do to fix the problem. As long as you start from that position there's really no point in trying. If you instead start from the position that something you did is causing the problem, then that gives you the chance to fix it.

By way of apology, i you wanted to send me either the full project, or preferably a stripped down version that has the error easily reproducible, I'd take a look.
 

Evanski

Raccoon Lord
Forum Staff
Moderator
then
everything freezes.
Its just the GMS2 that freezes,
IT doesn't freeze so I can't quite do that.
šŸ¤” So you don't have a problem then?

while { a++ }
just put a++ in the step event.
I challenge you to come up with a while construct that I can't come up with using a step event.
Well first of all that isnt how you use a while statment

Quote the document that would solve most of your threads
GML:
while (!place_free(x, y))
   {
   x = random(room_width);
   y = random(room_height);
   }
so in your example yes
you could just put a++ in a step event
because your not using a while loop

Most likely, The program is freezing not your game, and that's a software issue
 
Actually I challenge you to figure out what in the **** is wrong with my program. You get a medal if you figure that.
Send me a link to your project and I will have a look at it when I finish work this afternoon. Having someone go through your project and find any issues is probably the only way you are going to get things fixed as I doubt that providing (or not) small snippets of code on the forum is going to be the best way to get it sorted out.
 
Send me a link to your project and I will have a look at it when I finish work this afternoon. Having someone go through your project and find any issues is probably the only way you are going to get things fixed as I doubt that providing (or not) small snippets of code on the forum is going to be the best way to get it sorted out.
Agreed. Do you want to message me your email address and I'll send you an archive? Maybe you'll even have fun. My game is pretty unique. :)
 
@Twilight Raven
Okay, after working on this for a bit and figuring out how to the debugger works (first time for everything), I have tracked down what is happening.

Basically that in the bottom-left corner is your TwilightRavenLogoObject object that is being created, and that is why it then kicks you to one of the other screens - because that is what that object does. However, it took a bit of time to figure out why that object was being created when it is not being called anywhere in your project code.

I finally tracked the issue down to the Draw Event of your LightningBatObject, the following lines:
GML:
if (little_guy_flag)
{
    instance_create_depth(-40,900, -1100, MiniLightningSprite);
    little_guy_flag = false;
  
}
Your instance_create_depth is trying to create an object but is using the resource of a sprite MiniLightningSprite, and that sprite resource id must be the same as the object resource id of the TwilightRavenLogoObject. So that is why you are ending up in the situation you are.

I'm assuming that you are actually wanting to do:
GML:
if (little_guy_flag)
{
    instance_create_depth(-40,900, -1100, MiniLightningObject);
    little_guy_flag = false;
}
Because when I change it to the as above, it no longer has the issue that you were showing.
 
Well @BaBiA Game Studio Well it was a nice dream but I changed the code and it did the same as prior. So I just commented out the whole block of code and still same thing.
Once you have changed it make sure you have also cleaned your project (broom icon). It is definitely the fix as I ran it through several times after the fix and it worked fine.

Edit: I've also just redownloaded your project again, ran it without any changes (so it was exactly what you gave me) and it showed the issue. So all I changed was that one line, and it worked fine. So that is definitely the fix for it.
 
Last edited:

samspade

Member
@Twilight Raven
Okay, after working on this for a bit and figuring out how to the debugger works (first time for everything), I have tracked down what is happening.

Basically that in the bottom-left corner is your TwilightRavenLogoObject object that is being created, and that is why it then kicks you to one of the other screens - because that is what that object does. However, it took a bit of time to figure out why that object was being created when it is not being called anywhere in your project code.

I finally tracked the issue down to the Draw Event of your LightningBatObject, the following lines:
GML:
if (little_guy_flag)
{
    instance_create_depth(-40,900, -1100, MiniLightningSprite);
    little_guy_flag = false;
 
}
Your instance_create_depth is trying to create an object but is using the resource of a sprite MiniLightningSprite, and that sprite resource id must be the same as the object resource id of the TwilightRavenLogoObject. So that is why you are ending up in the situation you are.

I'm assuming that you are actually wanting to do:
GML:
if (little_guy_flag)
{
    instance_create_depth(-40,900, -1100, MiniLightningObject);
    little_guy_flag = false;
}
Because when I change it to the as above, it no longer has the issue that you were showing.
Nice job!
 

chamaeleon

Member
Well @BaBiA Game Studio Well it was a nice dream but I changed the code and it did the same as prior. So I just commented out the whole block of code and still same thing.
@BaBiA Game Studio has apparently done a great job debugging what happens. You should very easily be able to verify what an instance of TwilightRavenLogoObject does if one exists in the room at some point. When @BaBiA Game Studio says it kicks you to another screen, I'm assuming that means going to another room. If that is the case, there's some room_goto() or room_goto_next(), etc., call in an event or in a script that is called by an event. So why don't you verify this by simply using the tried and true show_debug_message() method of tracing what your program is doing?
 
@BaBiA Game Studio has apparently done a great job debugging what happens. You should very easily be able to verify what an instance of TwilightRavenLogoObject does if one exists in the room at some point. When @BaBiA Game Studio says it kicks you to another screen, I'm assuming that means going to another room. If that is the case, there's some room_goto() or room_goto_next(), etc., call in an event or in a script that is called by an event. So why don't you verify this by simply using the tried and true show_debug_message() method of tracing what your program is doing?
Just for some full transparency of what I discovered during my investigation of the issue:
The TwilightRavenLogoObject is only ever used in one place. This is the first room of the game, where the object shows the logo, plays a sound and fades out. Once the fade one has completed (all this is handled by the Step of the object) there is a room_goto that takes it to the next room which deals with the game title.

So the object is never again referenced anywhere else in the game, and is only being used as a company logo display (instead of using the default splash screen).

The only other time that the TwilightRavenLogoObject appears again in the game is when the issue occurs, and I tracked it right down to that block of code which I showed. This is where the code is clearly passing a sprite resource into the instance_create_depth function, instead of passing in an object resource. By passing in the wrong resource it is incorrectly creating an instance of the TwilightRavenLogoObject, which does what is detailed above - fades out and then does a room_goto to the game title room. This is exactly what the problem was, and by fixing the one line to use the correct object instead of a sprite the issue no longer happens.

Took a while to find it, but once I tracked down exactly where the issue was happening it wasn't too difficult to find the exact line that it was all happening on just by stepping through with the debugger. :)
 
Just for some full transparency of what I discovered during my investigation of the issue:
The TwilightRavenLogoObject is only ever used in one place. This is the first room of the game, where the object shows the logo, plays a sound and fades out. Once the fade one has completed (all this is handled by the Step of the object) there is a room_goto that takes it to the next room which deals with the game title.

So the object is never again referenced anywhere else in the game, and is only being used as a company logo display (instead of using the default splash screen).

The only other time that the TwilightRavenLogoObject appears again in the game is when the issue occurs, and I tracked it right down to that block of code which I showed. This is where the code is clearly passing a sprite resource into the instance_create_depth function, instead of passing in an object resource. By passing in the wrong resource it is incorrectly creating an instance of the TwilightRavenLogoObject, which does what is detailed above - fades out and then does a room_goto to the game title room. This is exactly what the problem was, and by fixing the one line to use the correct object instead of a sprite the issue no longer happens.

Took a while to find it, but once I tracked down exactly where the issue was happening it wasn't too difficult to find the exact line that it was all happening on just by stepping through with the debugger. :)
Congratulations are in order! Oh you a big one @BaBiA Game Studio. Don't worry, I have plenty more bugs for you to fix. :p:rolleyes:
 
Sorry. I wasn't trying to be rude. I was merely pointing out that if you're saying you didn't write the code that caused the problem, then there is literally nothing you can do to fix the problem. As long as you start from that position there's really no point in trying. If you instead start from the position that something you did is causing the problem, then that gives you the chance to fix it.

By way of apology, i you wanted to send me either the full project, or preferably a stripped down version that has the error easily reproducible, I'd take a look.
How about I take a rain check on that. I'm kind of iffy with who I shared m ycode with. At least, my partner is. If I come compress something I can fix by forum posts I'll taie you
up for sure,
šŸ¤” So you don't have a problem then?




Well first of all that isnt how you use a while statment

Quote the document that would solve most of your threads
GML:
while (!place_free(x, y))
   {
   x = random(room_width);
   y = random(room_height);
   }
so in your example yes
you could just put a++ in a step event
because your not using a while loop

Most likely, The program is freezing not your game, and that's a software issue
1) Poin
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object BatParentObject:
Variable LightningBatObject.receive_damage(101314, -2147483648) not set before reading it.
at gml_Object_BatParentObject_Step_0 (line 110) - hp-= receive_damage;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_BatParentObject_Step_0 (line 110)
called from - gml_Object_LightningBatObject_Step_0 (line 155) - event_inherited();


šŸ¤” So you don't have a problem then?




Well first of all that isnt how you use a while statment

Quote the document that would solve most of your threads
GML:
while (!place_free(x, y))
   {
   x = random(room_width);
   y = random(room_height);
   }
so in your example yes
you could just put a++ in a step event
because your not using a while loop

Most likely, The program is freezing not your game, and that's a software issue
Ther eis much wrong with this I'm not going to prove. Except that:

while { a++ } is a construct in a language I'm working on.
 

Evanski

Raccoon Lord
Forum Staff
Moderator
Variable LightningBatObject.receive_damage(101314, -2147483648) not set before reading it.
receive_damage in LightningBatObject isnt set to anything before the game reads it at LightningBatObject Step event line 155 while running event_inherited();
 
All that code is deprecated
Someone in this thread said something that might fix part of the problem, but I can't remember of the
life of me who said it or what it was.
 

Nidoking

Member
All that code is deprecated
Someone in this thread said something that might fix part of the problem, but I can't remember of the
life of me who said it or what it was.
Then the error message you posted is also deprecated. If you're having a problem, you have to post the actual error message you're getting if you want people to be able to help you.
 
Then the error message you posted is also deprecated. If you're having a problem, you have to post the actual error message you're getting if you want people to be able to help you.
Sorry I should have edited the post. I did the post and in the time changed the code.
 

Evanski

Raccoon Lord
Forum Staff
Moderator
Yeah, so receive_damage is no more. There, are we all happy? :rolleyes:
Where trying to help you here, were not required to do anything about your game, So sorry if I ask you dont get snappy when we try to help you with what YOU have provided us and CLAIMED is a problem
 
I don't know what kind of answer you're looking for. Is your game working properly? Do you need more help?
Game isn't working properly. That logo thing is going again and now I can't move my characters around. So I am redoing the map system since the old one sucked bad. So everything is on hiatus for now unless you know anything about hexagonal maps. @EvanSki I was joking around. Sorry I should have used a different emoji. I was rolling my eyes because it was an ordeal for a little bit of work. I apologize I come off sarcastic some times. That's the thing with communicating via text and not voice, there is no tone of voice which is a big part of communication. šŸ¤Ÿ
 
Where trying to help you here, were not required to do anything about your game, So sorry if I ask you dont get snappy when we try to help you with what YOU have provided us and CLAIMED is a problem
How do you change that title underneath your avatar. Like mine says "Member" which is pretty lame.
 
Game isn't working properly. That logo thing is going again and now I can't move my characters around.
It's doing the logo thing again because whatever you have done to your game since I told you the fix, you have also undone the fix that I gave you earlier in this topic.

As the problem was exactly the same as before, with exactly the same replication steps, the very first thing I did was go to the exact same lines of the LightningBatObject in the Draw Event, and what did I find there? This:
GML:
if (little_guy_flag)
{
    instance_create_depth(-40,900, -1100, MiniLightningSprite);
    little_guy_flag = false;

}
That is the bit that I told you previously to change to:
GML:
if (little_guy_flag)
{
    instance_create_depth(-40,900, -1100, MiniLightningObject);
    little_guy_flag = false;
}
So you have to do it again, and hopefully any other work on your game will not revert this fix back out again.
 
It's doing the logo thing again because whatever you have done to your game since I told you the fix, you have also undone the fix that I gave you earlier in this topic.

As the problem was exactly the same as before, with exactly the same replication steps, the very first thing I did was go to the exact same lines of the LightningBatObject in the Draw Event, and what did I find there? This:
GML:
if (little_guy_flag)
{
    instance_create_depth(-40,900, -1100, MiniLightningSprite);
    little_guy_flag = false;

}
That is the bit that I told you previously to change to:
GML:
if (little_guy_flag)
{
    instance_create_depth(-40,900, -1100, MiniLightningObject);
    little_guy_flag = false;
}
So you have to do it again, and hopefully any other work on your game will not revert this fix back out again.
I have NO idea how that got reverted. eek. Sorry for that. Thanks! :p
 
Top