• 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!

Room transfer help

ensomari

Member
I'm a decent ways into a game and I've done some room_gotos via pause and upgrade screens. I just made a main menu screen that has the following code:


if (menu_committed != -1)
{
switch(menu_committed)
{
case 3: room_goto(rMain); break;
case 2: room_goto(rHowToPlay); break;
case 1: room_goto(rSettings); break;
case 0: game_end(); break;
}
}

If I put a breakpoint in the switch/case block, my code works. If I let it run through without stopping to take a break, the game crashes with no error displayed. (X://windows/Runner.exe exited with non-zero status (-1073740791))

Am I missing something? Is there a simple strategy to make sure this works? Any way to force the output to be more verbose?
IDE 2.3.0.529 Runtime 2.3.0.401
 

kupo15

Member
Strange, not sure but no space after the switch perhaps?? Also just curious, why is there an if statement there when -1 isn't a case? Also, it might be a good idea to create an enum for your menu_committed values just in case you want to reorder the indices instead of hardcoding.

enum menuIndex {
gameTerminate,
settings,
howToPlay,
main

}

then you can

switch
case menuIndex.main: room_goto(rMain); break;
etc...
 

ensomari

Member
Thanks, valid and good code style suggestions. I'm just reusing the same style from a tutorial to quickly make screens. I still have the problem though. What do people normally do when no error is displayed when the game crashes?
 

ensomari

Member
Cool, I actually figured it out. Related to the copypasta coding I'm doing I guess.

in Clean Up... sprite_delete(global.screenshot); // Delete the saved screenshot

There was no global.screenshot variable declared yet. Weird how no error is displayed for this though, and weird that it worked with a debugger paused.
 
Top