The Dave's Game Maker Guide

The Dave's Game Maker Guide is a compilation of tutorials requested by Game Maker users. If you would like to submit a request, visit this thread at Starmen.net.

I. Introduction
In this tutorial, I'm going to talk about good naming conventions. Naming conventions help keep your projects organized and make sure you don't get any name overlapping. So, I'll talk about how I do my naming convention.

II. Prefixes
It's a good idea to attach Prefixes to your resource names so you know what you're dealing with. So for my sprites, I might use the prefix spr_ or for my objects, obj_, you get the idea. These 1.) identify your resources as sprites, object, rooms, etc. and 2.) allow you to use the "same" names for different resources. For example, I could have an object called obj_tree and I could then assign it my sprite, spr_tree. Without prefixes those two names would be identical and cause conficts, which is no good. The only thing I don't use prefixes for are scripts. I like to use them in code as I would built in functions.

III. Special Prefixes
When I make a special type of object or other resource I'll add a more descriptive prefix to it. For example, if I make a parent object, I usually attach par_ to the name instead of obj_. Or to differentiate between sound effects and background music, I'll use sfx_ and bgm_ respectively.

IV. Suffixes
Suffuxes are useful especially with sprites. Lets say you have an RPG project, your character will have several walking animations in all different directions, so, how do you organize them? I do it like this: spr_bob_wR basically, what that means is, this sprite is for the character bob, and it's of him walking right. See how that works? Likewise, I could have it a sprite called spr_bob_rDL which would be an animation of bob running down-left (or southwest).

V. Variables
For variables, I usually make them short and descriptive. For example, if I had a variable that kept track of player two's score, I would probably call it p2score, its short so my fingers don't get worn out typing it all the time, and descriptive so I know what it is when I look back at my code. I generally don't use underscores in my variable names, instead I just capitalize the next word, like in longVariableName.

VI. Script Names
For script names however, I generally do use underscores to seperate words. Like in draw_star or encrypt_string for example. If I'm making a set of scripts, I'll use a specific prefix for all of them. My online highscore engine scripts work like this - OH_connect, OH_send, OH_recieve, etc. This reminds you what exactly your connecting to, or sending to, or recieving from, etc.

VII. Conclusion
So there you have it, my naming conventions. Just remember, these are all just suggestions, feel free to do it your own way, or not have a naming convention at all. I think its a good idea to have one though, it makes life so much easier and organized.

If you have any questions or comments, post them in the topic mentioned above.
© 2008 David Arnold. Game Maker is a copyright of Mark Overmars and YoYoGames, Inc.