Hello, this is the first post of a series dedicated to technical aspects of game developing. Indeed we think that talking just about our games could be quite pretentious and as boring as hell. We’ll focus in particular on Game Maker Studio, since it’s our preferred tool to get things done. It has become especially nice since Yoyo Games put out the new update called Game Maker Studio 2. Well, maybe “update” is not the right word, since this has been a real overhaul – in a good sense. What’s better, one can import its old GameMaker projects into the new environment without hassle, since GMS2 comes with a life-saver import feature that has never failed us for now.
But for anybody who is starting a new project in GMS2, what are the main differences with the older version? The IDE has been refashioned and many editors have been improved, especially the room editor and the image editor. For example, an autotiling function and room inheritance have been introduced. All these changes are very well documented in the official manual and related websites.
What we want to talk about in this post are the less documented features that have been introduced in GML language. It can be a bit annoying to try to use a function only to discover that it has been deprecated or eliminated from the language, and to begin a search for its replacement. Thus we will try to cover the innovations in the GML language so that the reader can have a handy reference should he be lost at what function to use in certain circumstances. We’ll keep this post updated as we discover other changes or new ones are implemented.
Creating an instance
Old version: instance_create(x, y, object);
New version: now you can choose to create an instance either at a set depth or at a set layer, using
instance_create_depth(x,y,depth,obj) or instance_create_layer(x,y,layer_id_or_name,obj)
Now things can get a little more complicated, because GMS2 has introduced a new camera system which can be used together with the view system or in alternative to it; moreover, the old view system has now been limited in such way that you cannot manipulate views through code anymore except for some basic tweaks. For example, a code used to make the view follow the player object in 1.4 was like this:
view_xview = x – xview / 2
view_yview = y – yview / 2
but it wouldn’t work in GMS2. Instead you have to use cameras and view ports for that, for example:
camera_set_view_pos(view_camera, x – (view_wport / 2), y – (view_hport / 2))
The new camera system is thoroughly described in the official documentation here.
No more creating arrays by declaring a variable and then looping through it! Now it’s the 21st century and you can write
var a = [1, 2, 3, 4]
without risking the universe to implode!
And let’s not forget that there is a new little function called array_create( size, [val]) whose purpose you may easily guess.
The tile system is one of the things that has been completely overhauled (thanks to the heavens) and we want to spend a few words to explain how the new tile system works.
In GMS 1.4, basically, to manipulate tiles you had to put them onto a layer one by one and then use the available functions to resize them, set their alpha, set their visibility and so on. GMS2 now makes use of tilemaps, regions that are already filled with empty tiles that the developer can fill as they prefer. There are a lot of new functions and procedures regarding this subject so we will discuss them in a dedicated post.
You may have spent ages going through the header menu in Game Maker Studio 2 IDE loking for that little “macro” voice. Save your time because you aren’t going to find it there anymore. Or anywhere else, for that matter. Macros now can only be implemented through code with a simple syntax:
#macro <macro name> <macro value>
That’s it. Remember not to put the equal sign between the macro name and its value!