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

SOLVED "Grid index out of bounds" best practice?

Jam373

Member
So I have no actual bug, game is working as intended, it just so happens that for a single frame an object checks outside the grid before it's destroyed, I can easily fix this with a few lines of code. But it just got me wondering if I actually need to if everything works perfectly anyway. Would it be considered bad practice to leave these errors in? I'm assuming the error would never result in a crash or be noticed by a player but maybe different exporters handle this differently?

Sorry if this feels like a waste of time question, I was just curious and like learning about gamemaker.
 

GMWolf

aka fel666
The manual says that any invalid coords will return 0, so it is defined and all platforms will behave the same.

However you do get error messages (which can be annoying when trying to read actual errors).
There is also the issue that you cannot differentiate between the actual value 0, and an out of bounds value. It may not be an issue right now, but i would say its worth adding explicit handling of out of bounds to make any future edits more straight forward.
By not handling the out of bounds case now, you may make additional assumptions that make the code less flexible down the road.
 

Jam373

Member
The manual says that any invalid coords will return 0, so it is defined and all platforms will behave the same.

However you do get error messages (which can be annoying when trying to read actual errors).
There is also the issue that you cannot differentiate between the actual value 0, and an out of bounds value. It may not be an issue right now, but i would say its worth adding explicit handling of out of bounds to make any future edits more straight forward.
By not handling the out of bounds case now, you may make additional assumptions that make the code less flexible down the road.
Great answer, thanks! I'l be sure to add the code to handle it.
 
Top