Is glitching/crash due to global variables?????

Discussion in 'Programming' started by knightshaft, Jan 16, 2020.

  1. knightshaft

    knightshaft Member

    Joined:
    May 3, 2018
    Posts:
    44
    I'm nearing the end of completing my game. The opening room is the menu screen (loads fine), all the options in the menu work fine except for the 'Start' option. On a Mac I get the beach ball and/or glitching graphics for 1-2 seconds then it runs as it should. On an Amazon Fire tablet it just quits. So that leaves me only being able to test further on the Mac.

    The 'Start' option takes you to 'level 1' where all global variable are initilized for the first time. BUT..... they are also initilized in every subsequent level without glitching. There is also NO glitch when the game restarts and goes back to level 1.

    So essentially (unless I am missing something) the issue is with the first encounter with the global variables.

    I read that global are carried between rooms and with game_restart. So my question is....Does the first initilization require more processing/CPU power then subsequent initilizations?
     
  2. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,372
    Try making an empty room and put it at the very top of the resource tree. Open the room settings code box and initialize ALL your global variables there. Then put room_goto_next() at the end.

    A lot of things happen on initialization. It does sound like a memory allocation issue, but just setting variables shouldn't cause that much slowdown.
     
  3. knightshaft

    knightshaft Member

    Joined:
    May 3, 2018
    Posts:
    44
    Cheers. I was looking at that way. I did a few tests to see how the varibales were being carried around.


    What else is carried between rooms? It has to be to be smoething along those lines as it only happens once per loading of the game, no matter if its YM,YYC in either GMS2 or executable
     
  4. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,372
    Are your rooms persistent? If the answer is no, double-check anyway.

    The only other "big" thing I can think of are texture page sizes.

    Do long loops cause the cursor to ball up? What happens if you call
    Code:
    repeat room_speed*60 var a=0;
    Also, are you saying the global boot room moves the slowdown to before the main menu, or are you saying level 1 still has slowdown even with the boot room? If the boot room doesn't affect when the slowdown happens, then it's not the global variables (you should still use a boot room, though).

    Any large arrays? GM only handles arrays up to 32000 entries long. Anything beyond that requires GM to create a new array, which is somewhat slow (not ball cursor slow, but still slow).
     
  5. knightshaft

    knightshaft Member

    Joined:
    May 3, 2018
    Posts:
    44
    Rooms are not persistant. Not moved my variables yet, will do it tonight. The only 'ball up' is the one I have described. Textures could be an issue. Originally the background of the room was made up of 5 fairly low rez png files, now its probably about 100 files with some at full HD overlaying each other. When running the game GMS2 gives piles of warnings about resizing textures.
     
  6. knightshaft

    knightshaft Member

    Joined:
    May 3, 2018
    Posts:
    44
  7. knightshaft

    knightshaft Member

    Joined:
    May 3, 2018
    Posts:
    44
    It was a texture issue. I now have a working version on Fire
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice