Tips and Tricks to working with Gamemaker

 Gamemakerlab has been using game maker for a little over 5 years and have made a lot of games, an app, worked for clients, etc. One of the things that we see time and time again are hard coded, unnecessary checks, etc that slow down games and make them more complex than they need to be. So I've decided to write this to share all the tips and tricks summarized in a long time.Beside that  If anyone else wants to share their tips, please do!

1.Flexibility: whether you are making ai or just basic movement, make it as flexible as possible. Put it in a script and add arguments for all those values you need. Then you can easily change how it functions without having to dig through a mountain of code.

2.Syntax Help: For your scripts you want to make sure you add Syntax Help. When you type in a function and at the bottom of the code window it tells you what the next argument is, that is Syntax Help. The way you can do this is just at the top of your script add three slashes "///" and then the script name "///my_script" and then the arguments! "///my_script(move_speed,argument 1, anything, etc). The text doesn't matter but now you will get the suggestion box and the Syntax Help when you type it in!

3.Deactivate Objects You Don't Need: when an object is far enough away that the user can't interact with it or you don't need it anymore, deactivate it! object_deactivate() will free the memory and that object will not run any of its code anymore. Just remember that you need you reactivate it from another object!

4.Debug Mode: Something that will come in handy time and time again is a debug mode. This can be as simple as a button that turns on drawing of the x and y values on the screen. We usually write a little menu so we  can decide what we want to look at on the screen but you don't have to be that complex with yours. It's very useful to see what your object's coordinates are when it gets stuck, or the actual number value of your XP bar, maybe even an instance counter. It can be anything but it's best when you can monitor everything about your game. Sometimes you will find problems that you wouldn't have found otherwise!

5.Comment your code: It doesn't have to be right after you write a line but once you've finished the script, go back and write some comments at the top saying what it does and then each line of code telling why you did it and what it's for. This way when you return to the script you can quickly understand it again and you may even be able to improve it!

6.If you use argument[2] instead of argument2, you can add optional arguments to scripts. Use argument_count to check for them.

7.Use accessors! Instead of writing ds_grid_add( myGrid, 0, 3, myValue) you can write myGrid[# 0,3] = myValue

 8.Change the F2 drop-down snippets to your needs and use them!

That's all our  tips shared. In addition, if you have any tips or trick combinated with gamemaker, you could share at comment.

Thanks for reading and happy game making! 

 

That's all my tips for now, I plan on expanding on this when I get the chance but if anyone else has tips to share, please do so! Thanks for reading and happy game making! :)