4
\$\begingroup\$

Having started only recently with using GameMaker for game development (keep in mind that this is the first time in a long while that I'm doing something like this, so I'm technically at beginner level), I've lately been thinking about something that seems to be common place throughout creating a game with the software.

Through all the tutorials I've been through so far in GameMaker:Studio, I've noticed that the tutorials seem to want the names of game assets to always have a prefix in their names depending on what the game asset is, usually something like spr_ for sprites or obj_ for objects.

I've never exactly liked this sort of naming method, but I don't know whether or not to keep doing this or to just avoid using the prefix entirely. Does the engine require these prefixes for a game to compile or something?

Are these prefixes necessary?

\$\endgroup\$
4
\$\begingroup\$

No, this is just a coding convention on the part of the people who wrote the code. You can name your objects however you want (within reason... I'm sure $@#$ would not be a legal name).

The idea behind this convention is that you know what type an object is just by looking at its name, which is supposed to aid understanding while reading code. I don't really like it, either. :)

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ It's especially helpful when getting to work with GML. Resource names must be unique, and having this prefix system means you can have spr_player and obj_player as two differently-named but easily-identifiable resources. \$\endgroup\$ – Niet the Dark Absol Oct 19 '15 at 20:39
  • \$\begingroup\$ You bring up a good point, but I still wouldn't use this convention. I'd be more likely to do playerObject, playerSprite. This way, they alphabetize near each other, and you don't have all the xxx_ noise everywhere. \$\endgroup\$ – Almo Oct 19 '15 at 20:40
  • \$\begingroup\$ Maybe I'm just used to doing it that way XD Since Game Maker groups resources of a similar type together already, the problem of alphabetising is less of an issue. To each their own, however, and so long as it makes sense (which yours does) and is consistent (I'd gladly adjust my naming conventions to match yours if we were working on a project together), then all is well. \$\endgroup\$ – Niet the Dark Absol Oct 19 '15 at 20:42
  • 1
    \$\begingroup\$ One of the reasons some people put the type as a prefix rather than as a suffix is to leverage autocompletion. By starting with obj_ (or just o) you get a list of every object that you can then navigate or filter if you don't remember a particular name. \$\endgroup\$ – Darkhogg Oct 19 '15 at 23:02
  • \$\begingroup\$ Admittedly the last time I used Game Maker was over 5 years ago, but at the time, all game resources were kept separate in the UI, so even naming them similarly would never have them end up next to one another. Additionally, this convention was extra important since these identifiers simply resolved to numeric IDs which were only unique within their own category. This meant you could give an object ID where a sprite ID was expected and everything would "work", although not in the way you intended usually. \$\endgroup\$ – Kyle Oct 19 '15 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.