So, for my first tutorial on GameMaker, I thought I would first help people familiarize themselves with the engine, so that everyone will be able to follow along the next tutorial, where I’ll be teaching how to code on GM:S and GMS2.
On this tutorial you’ll be learning:
- What are assets and what each type do.
- What the most important of the object events do.
As this tutorial has a high focus on beginners, I’ll try to explain everything as best as I can.
Those small folders you see (Left for GM:S 1.x, Right for GMS 2) are different kind of Assets. Assets are basically what you’re game is made out of; images, sounds, code, everything the game needs to run. Each of these assets has different properties, so bear with me while I try to explain each of the most important.
- Sprites: A sprite is an image that you can display on your game at any given time. You may use it to represent an object (detailed below) or you can just display it independently. If you are using GameMaker Studio 2, you can also display them as background images with loads of cool properties, since GMS2 doesn’t use backgrounds like GM:S does.
TL;DR: Any image on a GameMaker game is a sprite, basically.
- Sounds: Sounds are, well, sounds. They may be simple soundFX or long soundtracks (a.k.a musics). You can play them on code whenever you want!
- Backgrounds: For those on GameMaker:Studio (1), backgrounds are still images used on the, well, background of your game. They don’t have much use other than that, hance why they don’t exist at all on GameMaker Studio 2.
- Scripts: A script is a piece of code that are mostly used to substitute having to type the same things over and over. Once created, they can be called on code just like a function (which will be explained on later tutorials).
- Shaders: Shaders are pieces of codes that runs directly on the users GPU, rather than the CPU. They can change a lot how your game looks. They are coded on another language, called OpenGLSL ES. If you’re interested on learning how to use them, I would recommend looking at this guy’s tutorials: http://xorshaders.weebly.com/tutorials. Although I do not recommend it to beginners.
- Fonts: Just like on your Notepad or Word, they change the way your text looks and the size of it.
- Objects: Here is where all the magic happens. Objects, just like in real life, are things that do something, have a purpose and can be interacted with. They will hold, at least, 80% of your game’s code, so they are pretty important. They have those things called “Events”, which I’ll explain below.
- Rooms: Last but not least, rooms are where you’ll put objects and backgrounds. You can set different cameras and views on them, which I’ll explain on my coding tutorials. If you’re on GameMaker:Studio, they also control the framerate of your game.
Those were the assets that I find the most important and the ones I frequently use on my games. If you’re interested on the others, you may want to look on other tutorials, since I don’t plan on explaining them.
(Image of how object editing works in GM:S 1.x and GMS 2, respectively)
As I said above, objects hold most of your game’s code, but what I didn’t say is that objects contain different types of events, which basically controls when certain piece of code is triggered/should be run. Since there are so many different events, I’ll be listing only the ones I think are the most important ones.
- Create Event: The create event is a piece of code that only runs exactly when the object is created (a.k.a appears on the game), which makes it perfect for variable initializing
- Destroy Event: Contrary to the create event, the destroy event is only run on the exact moment an instance of the object is being destroyed (a.k.a it’s not on the game room anymore and it won’t run code anymore).
Instances can only be destroyed with the function “instance_destroy()”
- Step Event: Step events are run once by frame on your game, so if your game is running on 60FPS, it will run 60 times per second. You may find that there are 3 variants of the Step Event: Begin Step, Step and End Step. The only difference those variants cary are the order they are processed. Begin Step is 1st, Step is 2nd and End Step is 3rd. Since the Step Events are one of the first events to be processed, it’s usually the event that carry most of the code you got, with a few exceptions.
- Draw Event: Draw events work just like Step Events, except that they always run AFTER the End Step and that they can use the “draw_” functions, which means they can display sprites, text and other stuff steps can’t do. There is also the Draw GUI event, and this works a little differently, so I’ll try to explain them with an example; if your game has a focus on pixel art, the game camera may be very zoomed in, which means that 1 game pixel will be displayed with dozens or even hundreds of “real pixels” (a.k.a the little squares your screen is made of) on the regular Draw Event. As you can see, zooming the camera in or out directly affects how the regular Draw Event draws. However, it won’t affect the Draw GUI Event, so if you were to draw pixel art with it, it would always display 1 pixel of the image as 1 pixel on your screen (1:1), regardless of how the camera is zoomed. TL;DR: Zooming the camera will affect the Draw Event, but won’t affect the Draw GUI Event. The other difference both events have is the coordinates X and Y. For the Draw Event, the X and Y will go from [0,0] up to the game’s room width and height, while on the Draw GUI Event X and Y goes only up to the window’s width and height (which is usually smaller than the room)
- Game End: Runs once the game is about to be closed. It’s usually used to save the game and destroy dynamically created data structures, which I’ll cover on later tutorials.
Now that all of this stuff is exaplained I will be starting real coding tutorials, where you’ll learn how to make players, enemies, solid stuff and more. If you didn’t understand something, don’t panic, as you create more games, you’ll get the hang of how stuff works. Additionally, you can ask me personally on my twitter: http://www.twitter.com/Syndelis. I’ll be glad to answer everything you want (related to coding, of course).