Game maker studio training. GameMaker - Various lessons

Game maker studio is a good cross-platform design engine for creating 2D games. The engine has a very simple and understandable interface, but if you have any difficulties mastering it, then it will help you a large number of documentation in Russian, video lessons and forums on working and creating games on this engine.

The Game maker Studio editor makes it possible to create games not only 2D games, but also use 3D graphics. It is worth noting that the ability to create 3D games will not please you with cool modern graphics or a high degree of optimization, so this engine should still be used as a platform for creating high-quality 2D games.

The engine allows you to create 2D games using your own sprites (graphical objects in computer graphics), sounds and animations, which can also be created and edited in Game maker studio.

An integral advantage of the Game maker studio editor is cross-platform - this is the ability to create your own games for different platforms for PC (Windows, Mac OS, Ubuntu), mobile (Android, Amazon Fire, iOS, Windows 10 Mobile), Web (HTML5) and Game consoles (Xbox One, PlayStation 4).

You can't help but notice the built-in store of sprites, sounds, maps, animations, etc. This makes it possible to quickly and easily create games without being distracted by creating individual parts, such as the appearance of the character or its animation.

For beginners

Game maker studio is suitable for ambitious people with interesting ideas to create a game prototype. Now the big problem with a good idea for creating a game is its implementation, since this requires knowledge of programming languages. This engine makes it possible to create a game without resorting to programming or writing scripts.

It is very suitable for the first test creation of the mechanics of a planned game, since the main thing to begin with is to understand whether the gameplay itself will be interesting, and only after testing it will be possible to begin the detailed creation and improvement of the graphic part of the game. Game maker studio is suitable for such purposes; it makes it possible to quickly and easily implement this kind of task.

Drag and Drop (DnD™) is a graphical development environment that is ideal for beginners or those who are more visually or artistically oriented. With DnD it is possible to create games without writing scripts, using only the program interface.

Also, for beginners in working with Game maker studio, the Russified interface, which can be found on the forums of this engine, will help. The official one also contains a large amount of documentation and instructions for working with the engine.

For professionals

But it goes without saying that the Game maker studio engine will not be of interest to professional Game developers. Game maker studio has its own programming language GML, which is written in Delphi and has the syntax of Java Script and Pascal. When creating a game using GML, the programming language opens up many more possibilities rather than through graphics editor programs.

Interface overview

The latest version of Game maker studio No. 1 was 8.1.140, today it is no longer supported, so it was released a new version Game maker studio 2.

Game maker studio 2 is freely available on the official website of the engine. The free version can be downloaded from the link https://www.yoyogames.com/get, it is designed for free use and with a limited number of tools, but this will not prevent you from creating your first project. For download free version you need to register on the site.

Also on official forum You can download the crack for the engine.

After you have downloaded and installed Game maker studio, launch it and in the window enter the data that you registered on the official website when downloading. After entering the data, the engine interface opens.

Since we are using the free version of the program, the “Study” category will not be available to us.

In order to start developing the game, click on the “Create” button and in the next window “Drag and Drop”, after which a window will open in which you need to come up with a name for the project and save it in a convenient place for you.

After the workspace opens, you can see tabs on the right side of the window, where our parts of the game will be sorted.

In order to start working and creating objects, we will need to right-click on the empty space and select “Resources”. In the window that pops up, select what we will start developing from.

When creating a sprite, the creation menu will open to us, animated characters of our game. Here you can draw a character completely from scratch, pixel by pixel, or import a ready-made one. Also animate it, create frame-by-frame animation of the character’s actions.

To create a map, we need to select “Resources”, and then in the pop-up window “Create a room”. The room editor provides the ability to set the size, background, set interaction elements, place characters, draw paths, etc. In the room editor you can also import a ready-made background or create one yourself using this editor.

Event creation can be done without resorting to programming or scripting, everything is done using fairly intuitive menus and windows. You can think through and create quite complex action scenarios for an object using the visual editor Game maker studio.

Using the parameters, you can select the platform for which the game is being created and fine-tune the game, such as the size of the window for playing the game, versions, shortcuts, startup screens, etc.

It is worth noting the part of the program in which we are given the opportunity to work with code in GML. I'm very pleased with the ease with which simple command functions can be done. Therefore, if you are a beginner Game creator and are ready to devote most of your time to this, then you simply need to start learning the GML language.

Installing a cracker

For beginners, it would be better to install a Russian-language interface to make it easier to navigate. To do this, you need to download the crack file, the link to which is above.

After downloading the Russian language file, copy it and paste it into the directory with the Platform in the “Languages” folder, which is located at the following path C:\Program Files\GameMaker Studio 2\Languages
Open the inserted file in Notepad, to do this, right-click on it and select “Edit”.

Notepad will open with the configuration of this file. We need to insert the following configuration in the 7th line.

LanguageCode,ru,ru,standard windows os language code this pack represents (can be primary code only ie. en or primary-secondary ie. ru-RU)

Save the file and make a backup of the standard “english” file; to do this, simply copy it to another folder. This is necessary so that if something goes wrong, you can simply copy it back and return the original engine language. After saving the Russian-language file, delete the old English-language file (previously saved in another folder) and launch Game maker studio.

Results of the Game maker studio review

Pros:

Minuses:

  • Poorly optimized for some platforms.
  • The tool for creating 3D games is poorly implemented.
  • There is no built-in Russian-language interface.
  • There are big restrictions when using the free version (that's why it's free).

Conclusion

Game Maker Studio is a cross-platform game engine with easy learning and detailed documentation. The program offers an intuitive and easy-to-use Drag-and-Drop (called "DnD" now) "action icons" interface that will allow you to start creating your own games very quickly. You can import and create images and sounds to use in your game, and then instantly see the results of your actions at the touch of a button. It should be noted that GameMaker: Studio is designed for 2D games (but there is also basic support for working with 3D). With the help of D&D, anyone without programming knowledge can create a simple game like Mario or Tetris.

If you love games, you've undoubtedly wondered how they are made. If you have (or will) have a desire to make games, but have no experience, in this article I will talk about the best way to start.

Introduction

Game Maker is incredibly simple game engine, which allows you to create games for a large number of platforms - Windows, Mac OS X, Ubuntu, Android, iOS, Tizen, Windows Phone, Windows 8, PlayStation 3, PS 4, PS Vita, Xbox One and HTML 5. There is support for SteamWorks. If your game is successful, porting to another platform will not be a difficult task.

The speed of development, even with modest knowledge and minimal motivation, is subjectively faster than on other engines. Installation and configuration for beginners is as simple as possible and does not require special knowledge. Compilation for other platforms does not require changing the game code and is done with one click (well, almost).

YoYoGames, the company behind Game Maker, was recently acquired by Playtech, making sure that Game Maker will continue to grow. The announced Game Maker 2.0 will likely be even friendlier and simpler, and it is logical to assume that it will have even greater capabilities. As they write in the press release, GM 2.0 is one of the reasons for purchasing the company.

In this article I will briefly talk about Game Maker and we will make a simple sketch of the future project.

Who is this engine for and for what purpose can it still be used?
For all. The target is any 2D game. However, for those for whom programming is not a native element, as well as for rapid prototyping and creating a game with minimal effort for anyone who wants to make games and/or make money on them, Game Maker is ideal.

Pros of Game Maker

- simple entry;
- syntax familiar to everyone from Java/C/C#...;
- the ability to easily compile on different platforms;
- an active community that has already solved many problems over the years and written the code for you;
- standard functionality, thanks to which you do not need to write a large amount of code yourself;
- extensibility through extensions;
- Help (F1) is very simple and convenient with excellent explanations and examples.

Cons of Game Maker

- paid (when you grow up to publish the game, you will have to buy a license);
- no auto-substitution of user variables, only for standard and script ones;
- high cost of the maximum license (however, not everyone needs all the modules);
- technical support (I contacted technical support twice, they didn’t answer me in less than 2 weeks);
- there is no possibility of auto-referencing.

Now to creating the game. I think installing Game Maker and creating an empty project is not a problem. In general, for starters, it would be good to think through all the functionality, draw diagrams, think about monetization, etc., but this is not the purpose of the article, so I will show you a way to create a project for a novice game developer.

Let's briefly go over the structure of the project:

  • Sprites - folder with sprites (images, animations);
  • Objects - objects with their own prepared events (for example, creation, drawing, click, etc.);
  • Rooms - game rooms (screens). For each screen you need to make your own room. Very comfortably;
  • Background - backgrounds with which you can fill the room. Also used as tile sets
The rest doesn't interest us for now.

What is a sprite in Game Maker?

This is the image/animation used in the game. They have their own mask, the shape and size of which can be changed. A mask is an area of ​​the image that reacts to object collision events (if this sprite is assigned to some object) and clicks on it. You can set the drawing point (Origin) - for example, from the center, corner or any other point.

You can also set a Texture Group for a sprite. Needed to optimize rendering (for example, there is no need to keep texture pages with images in memory that are used on the menu screen when we now have a game screen). For each Texture Group, you can specify the platform on which they will operate. For example, Android may have less detailed images than Windows 8 tablets.

What is an object in Game Maker?

This is a description of some entity that has its own methods (functions). Each object draws itself (unless otherwise specified), reacts to standard events - keypresses, clicks on a sprite, etc... By analogy with OOP, this is a class.

What is an instance in Game Maker?

If an object is simply a description of an entity, then an instance is an instance of an object, its implementation in the game itself. By creating an instance, you give it life and now all events whose description is in the object will begin to react.
By analogy with OOP, this is an object.

The first thing you need to do is create a new room (in the left panel, right-click on Rooms - Create Room). Let's call it rm_game. Let's set the window sizes in the Settings tab - Width - 800, Height - 480, Speed ​​- 60. I.e. Our game will take place in a window of 800x480, fps will not exceed and tend to 60 frames. Save and close.

Let's add some sprites. Right click on the Sprites folder -> Create Sprite. Let's call it spr_unit_shooter, upload an image (available on Github at the end of the article), for example, size 54x54 and center it (Center button). “OK” button and the data is saved.

Now we need the first unit. Let it be a classic shooting plant. But before that, we would like to create an object that will be the parent of all user units (yes, approximately the same as inheritance in OOP). This way you can avoid repeating logic for all units, and also, as you will see below, you can access all types of “children” of this object created during the game.

Using a similar principle with sprites and rooms, we create an empty object. Let's call it o_unit_parent and don't do anything else with it for now. Now let's create o_unit_shooter and select o_unit_parent in the Parent column. Let's give it a sprite - spr_unit_shooter. To do this, use the button located under the name.

Name sprites, objects, rooms, etc. you can do it as you wish, but in order not to get confused later, it is better to immediately call things by their proper names, for example, sprites with the prefix spr_, objects obj_ or o_, scripts - scr_, etc.

Now, every time you create an o_unit_shooter object in a room, it will automatically draw the sprite you select (unless you override it with code, of course).

The sprite can also be set programmatically, but in this case it will not be displayed in the Project Structure preview on the left. Now let's add an event that will be triggered when an object instance is created. In this event you need to set the initial initialization of variables, if any. Click Add Event. As you can see, Game Maker allows each object to catch a large number of events. We are interested in - Create.

As you can see on the right, in the Actions container in several tabs there is a huge number of drag"n"drop elements, with the help of which, in theory, you can create a completely full-fledged game without writing a single line of code. But this is for perverts and probably in Game Maker 2.0 this unnecessary functionality will finally be removed.

Let's go to the Control tab and drag or right-click on the Execute code icon. A text editor will open in which you can place game logic.

As you remember, units must shoot at a certain period. This can be done very easily. In the Create event we will write this code: alarm = room_speed * 2;
This means that we launch alarm number 0, which will trigger after room_speed*2 steps (frames). our room_speed is 60, which is approximately equal to a second. So the alarm will go off after 120 frames (2 seconds). alarm is a function, or rather an object event, it is triggered as soon as the step counter reaches 0. Like all other events, it is added via Add event. Now we need to write the logic that we will add to alarm, but first let’s create what our plant will shoot with.

Create a new sprite spr_bullet, size 16x16 and center it. Now we create a new o_bullet object and give it the newly created sprite. In the Create event, add the code hspeed = 7; exactly the same as with the previous object. With this line we specify that the object will move at a horizontal speed of 7 (hspeed = horizontal speed, if anyone doesn’t understand). This is a built-in property of every object. By assigning a non-zero value to it, this object will begin to move by specified quantity pixels (in our case 7 to the right) each step (Step). If we set hspeed = -7; - the object will move -7 pixels each step, i.e. will move from right to left.

That's it, let's return to the o_unit_shooter object and create a new event - Alarm 0. The code that we write in this event will be triggered when the counter that we created in the Create event is launched. In the Alarm 0 event we will create “bullets” (in the original - peas) that the plant shoots. Let's add this code:

/// shoot var b = instance_create(x + sprite_width/2, y, o_bullet); b.depth = depth + 1; alarm = room_speed * 2;
Let's analyze this code.

/// shoot is just a comment that will be displayed when going to the event. By default, “Execute piece of code” is shown, which is not very informative. So it is recommended to write such comments so as not to waste time going to the code editor.
var b = instance_create(x + sprite_width/2, y, o_bullet);
var b - we declare a local variable that will be available exclusively in this event. After the event completes, the memory will be freed and you will not be able to access this variable.
instance_create(x + sprite_width/2, y, o_bullet); - this is how we create a new instance of the object and place it at x coordinates: x + sprite_width/2, y - y. IN in this case x and y are the coordinates of the mother object - o_unit_shooter. o_bullet is the object we are creating.
b.depth = depth + 1; - this line means that the newly created o_bullet instance will be located 1 layer lower than o_unit_shooter.
The last line means that we run alarm again - the plant should constantly shoot.

As you remember, in the original you can place vegetation only in certain cells. To make it visually clear within what limits the plant can be placed, let’s create a background and fill our room with it. Right-click on Backgrounds - Create Background - Load Background, select the desired image, say 64x64 pixels, call it bg_grass. Go to our room (rm_game), Backgrounds tab, select the background created a second ago. Please check the boxes if they do not appear as in the image.

Now we need some kind of starting object that will do the initial initialization. We create a new object and call it, for example, o_game. Let this object react to a click on the field. To do this, add an event - Mouse -> Global mouse -> Global left released. A regular mouse event means a direct click on an object, but since o_game does not have its own sprite+mask, etc. we need the player to be able to click on any point on the playing field; we need to catch all click events. That's exactly what Global Mouse does. Global left released means that somewhere inside the game window a mouse click or touch on the touch screen was made (the event is triggered when the finger is released).

Let's add the following code to this event:

Var tBgWidth = background_get_width(bg_grass); var tBgHeight = background_get_height(bg_grass); var iX = mouse_x - mouse_x % tBgWidth + tBgWidth; var iX = mouse_x - mouse_x % tBgWidth + tBgWidth/2; var iY = mouse_y - mouse_y % tBgHeight + tBgHeight/2; if (instance_position(iX, iY, o_unit_parent) != noone)( exit; ) instance_create(iX, iY, o_unit_shooter);

You don’t have to put a semicolon after the operation; this does not change the logic of the code and will not cause errors. But if you can bet, why not do it. Yes, and more familiar.

In the first four lines we declare local variables. background_get_width, background_get_height are built-in functions that return the width and height of our background. As you can see, we will need this data in order to calculate iX and iY. iX and iY will be the coordinates at which we will instantiate the o_unit_shooter object. mouse_x, mouse_y - global variables built into Game Maker (i.e. those that we can access from anywhere) that store the current coordinates of the mouse cursor (finger). Because we work in the Global left released event, they store the last coordinates where the user released the left mouse button (released his finger). Mathematical operations, the results of which are assigned to the variables iX, iY, are needed to calculate coordinates in which an instance of the o_unit_shooter object will be located exactly in the middle of the background cell bg_grass. Those. remember that in Plants Vs. Zombies plant You can’t place it anywhere, only at a certain point, but you can click anywhere and the plant will be placed exactly in the right place. This is what all the code above does.

Checking instance_position (iX, iY, o_unit_parent) != noone means that we look at whether any instance (object instance) whose parent object is o_unit_parent is located at coordinates iX, iY. Since we now have only one inheritable unit - o_unit_shooter, we check if there are any instances of o_unit_shooter on the playing field, but we write o_unit_parent in the check so that the code will work even when we add new custom units. noone (from “no one”) is a kind of analogue of null in other languages.

Exit - code that terminates the execution of the event. Those. if there is already a unit at coordinates iX, iY, exit is triggered and the o_unit_shooter instance is not created, because we interrupt the execution of all subsequent code. We need this so that 2 user units cannot stand in one cell.

Well, it's time to add the first enemy. Let's create a new object and again create a base parent object. Let's call it o_enemy_zombie and o_enemy_parent, which will be its parent. Let's create a sprite spr_enemy_zombie, center it and assign it to o_enemy_zombie.

Since the property of all enemies is to move towards plants, we will create this code in o_enemy_parent in the Create event:

CHspeed = -4; hspeed = cHspeed; HP = 10; canAttack = true;
cHspeed is a user variable whose value we assign to hspeed, which we've already seen. Why not just write hspeed = -4; - you'll see later.

Previously we declared user variables using the var construct, but we don't do that here. What is the difference between cHspeed = -4; and var cHspeed = -4;?
Everything is simple - in the first case, the variable will be accessible from any point in the code of this object and can be accessed from any other object, but only without forgetting to mention which object we are accessing. There is no need to delve into this now. We remember that this variable exists for the entire lifetime of the object instance from the time it is declared. In the case of var cHspeed = -4; it will be available only for the duration of the event in which it was created.

In fact, you can also access it from another object, but if you access it from another object at the moment when the event in which it was created has already ended, this will cause an error - the familiar null pointer, because it is already out of memory unloaded.

If you don’t like the hspeed or wspeed functions yourself, you can implement them yourself by changing the x or y value in the Step event. These features simply do it for you.

HP is another variable in which we will store the number of hit points of enemies. Each instance will “own” this variable, but the maximum number of hit points for different types different enemies, i.e. you need to somehow redefine/reset this value. Or you can give all enemies the same number of lives, say, 100, and introduce the concept of defense, on which the damage the enemy receives will depend, but now there’s no point in complicating things, right? So we'll make do with just one variable - HP.

Remember, gml is the language used in Game Maker and is case sensitive, HP, hP, Hp and hp will be different variables.

CanAttack is simply a variable to which we assign the value true. For now, we’ll just write and forget about it.

Since our HP value will be different for each enemy, we need to somehow redefine this value. It's very, very simple. Let's go to the o_enemy_zombie object, create a reaction to the Create event and write the code:

Event_inherited(); HP = 20;
Function event_inherited(); and deals with inheritance. Those. now o_enemy_zombie will execute the code:

CHspeed = -4; hspeed = cHspeed; HP = 10;
Which this function “imports”, and then the value is executed by the line - HP = 20;
Those. in fact, at the end of the Create event, the o_enemy_zombie object will have the following properties:

CHspeed = -4; hspeed = cHspeed; HP = 20;
If we forget about the event_inherited(); or we forget to specify the parent object for the o_enemy_zombie object, the enemy will not move, and an error will appear when trying to access the cHspeed variable of this object.

Great, if we want to create another type of enemy, in the Create event we will write the same thing, changing the amount of HP to the required amount:

Event_inherited(); HP = 100;

Since zombies have hit points, the plant should have them too. Add the code HP = 20; to the Create event of the o_unit_parent object yourself. and the line event_inherited(); into the Create event of the o_unit_shooter object.

Do you know?

If you do not need to redefine or add anything in the Create event, add the code event_inherited(); There is no need for any other logic in the event - Game Maker itself will do it for you. The same applies to any other events, not just Create.

Great, our zombie is now walking, but the bullets don’t hit him and the plants don’t slow him down. Let's solve the first problem first. Let's go to o_bullet and create a new reaction to the event - Add Event -> Collision -> o_enemy_zombie. This event will be called when o_bullet and o_enemy_zombie crash into each other. The collision is checked using the mask that you read about at the beginning of the article. Let's add the code:

With(other)( HP -= 5; if (HP<= 0){ instance_destroy(); } } instance_destroy();
This is a very interesting point. other is the instance of the object with which a collision occurs at this moment of the event. Naturally, because this code is in the collision event with an instance of the o_enemy_zombie object, then in other there will only be an instance of o_enemy_zombie.

With()() we access this other element. Everything that happens inside () concerns exclusively this instance of the object. Thus, HP -= 5; - This is the subtraction of 5 life points from the enemy. In if(HP<= 0){} мы сравниваем количество очков жизни тоже именно у этого объекта. Помните я немного выше говорил про разницу между обычным объявлением переменной и с переменной через var. Вот этот пример должен вам окончательно прояснить ситуацию. Т.к. переменная HP у нас объявлена не через var, то она доступна в любой момент времени. Так что с помощью конструкции with мы можем к ней получить доступ. Альтернативный способ обращения к переменной другого объекта выглядел бы так:

Other.HP -= 5; if(other.HP<= 0){ with(other){ instance_destroy(); } } } instance_destroy();
But accessing variables this way is less convenient, especially if there is more logic, but nevertheless applicable in some cases.

Don't forget, if you didn't declare a variable in the Create event, and in code you access it before it's declared, it will throw an error if you try to read any data from it.

You don't need to have much knowledge of English to understand that the instance_destroy(); function; deletes this object instance (instance).

Thus, all this code means that during a collision we take away 5 life points from a zombie and if it becomes 0 or less, then we destroy it. Regardless of the result, at the end we remove our bullet. It couldn't be simpler. In general, it would probably be better to force zombies to monitor their health on their own, but for now we are not interested in that. But that's another story, a question of optimization.

It wouldn't be right if our zombies could only take damage. We need to add the ability to cause damage. First of all, let's add a new variable to the Create event of the o_enemy_parent object

IsActive = true;
It's time to take a look at the Step event that I talked about earlier. This event fires every frame. It's simple. If room_speed is 60, then this event will fire approximately 60 times per second. Let's add this code to the Step -> Step event of the o_enemy_zombie object.

If (!isActive) exit; var tBgWidth = background_get_width(bg_grass); var leftCellCenterX = x - x % tBgWidth - tBgWidth/2; var frontEnemy = instance_position(leftCellCenterX, y, o_unit_parent); if (frontEnemy != noone)( var frontEnemySprtWidth; with(frontEnemy)( frontEnemySprtWidth = sprite_width; ) if (x - sprite_width/2 - frontEnemy.x - frontEnemySprtWidth/2<= 12){ hspeed = 0; if (!canAttack){ exit; } canAttack = false; alarm = room_speed * 1.2; // cantAttack ->true; with(frontEnemy)( HP -= 5; if (HP<= 0){ instance_destroy(); } } } }else{ hspeed = cHspeed; }

There is nothing wrong with it; almost all the designs are already familiar to you.
if (!isActive) exit; - if the object is not active, i.e., say, resting/recharging/making a swing, this event will not be executed. In the next two lines we get the coordinates of the center of the cell located to the left of the one on which the center of our instance is currently located (remember that x returns the coordinates of the Origin point, and we have it set exactly in the center of the sprite). Next we look to see if the user unit is located at coordinates (leftCellCenterX, y). If there is something there, subsequent logic occurs, but more on that in a second; if there is nothing there, we assign hspeed the value of the cHspeed variable, which we, remember, create in the Create event. This is where it came in handy. The meaning behind this is this: if our zombie stopped to attack and destroyed the plant, he needs to continue on his way. You can, of course, not enter the cHspeed variable, but then you will need to remember where you set the speed of movement, and this is forgotten.

This is if there is nothing in the way of the zombies, but now we return to the moment when we have to fight. The very first lines turn out to be very interesting, with a catch. The fact is that by declaring the local variable frontEnemySprtWidth, we assign a value to it in the frontEnemy instance. Those familiar with programming will say, but in this case we are accessing the variable frontEnemySprtWidth not of our zombie, but to a variable with the same name, but of the frontEnemy instance. Well, not so, the point is that local variables (declared via var) become visible inside this event everywhere, even from inside the frontEnemy instance. Thus, there is no error in the code; we are actually accessing exactly the variable that was declared local inside the zombie. If you do not understand this point, experiment or read the help, everything is perfectly explained there, and we move on.
We assigned frontEnemySprtWidth the length (width) of the sprite of the user unit (plant), which is located one cell to the left of our zombie. You will say, why do we need to fence off such a difficult-to-understand construction when we can get by with var frontEnemySprtWidth = sprite_get_width(spr_unit_shooter);. The answer is simple - now we have one plant and we know which sprite to contact, but when adding new types of units (sunflowers, etc.), we will have to construct a cumbersome switch construct to find out what kind of object is in front of us, and that’s enough this problem is simply solved.

Next, we check if the distance between the rightmost point of the user unit and the leftmost point of our zombie is less than 12 pixels, then we stop our zombie, check whether our zombie can attack (we check the value of the canAttack variable previously created in the Create event of the object o_enemy_parent), continues execution code in which we say that it is now impossible to attack and that next time it can be done through room_speed * 1.2 frames (after 60 * 1.2) - we do this in alarm (add it yourself to the corresponding event (Alarm 0) of the o_enemy_parent object , where write the code canAttack = true;). If it is possible to attack, we take away 5 life points from the plant instance and check whether it is still alive; if not, we destroy it.

Well, the enemy is perfectly prepared - he moves, attacks and continues to move if he has destroyed the plant, but he has one drawback - it does not exist. We have only created a description of our enemy, now we need to place zombies on the playing field. We return to the Create event of the o_game object. Let's add the code
alarm = room_speed; // generate enemies

Those. after 60 frames Alarm 0 will trigger and a zombie will be created, right? No. We did not create logic for this Alarm. And the code here is also simple:

Var tBgHeight = background_get_height(bg_grass); var eY = irandom(room_height - room_height % tBgHeight); eY = eY - eY % tBgHeight + tBgHeight/2; instance_create(room_width + sprite_get_width(spr_enemy_zombie)/2 + 1, eY, o_enemy_zombie); alarm = room_speed * 3;
Everything is simple - we won’t complicate it and just create an o_enemy_zombie instance at X coordinates every 3 seconds (60 frames * 3): room_width + sprite_get_width(spr_enemy_zombie)/2 + 1 i.e. exactly one pixel to the right than the screen border, i.e. zombies will not be visible initially and Y is a random cell. room_width and room_height, as you already understood, are the width and height of our room. Those. 800 and 480 respectively.

This is all great, but someone must also create an instance of the o_game object, otherwise the whole episode makes no sense. But our final step is very simple - go to the room rm_game -> Objects -> select o_game in the menu and place it anywhere in the room. An alternative option looks like this - Settings tab -> Creation Code (this is the code that will work when we go to this room). Add the line instance_create(0,0, o_game);

Any coordinates are possible. Now we can ask the question, how will Game Maker determine that it needs to start the rm_game room or “what if we have many rooms, which Game Maker will start with?” Everything is as simple as always - the topmost room starts first (their order can be changed by dragging with the mouse). Now we have only one, so it will start right away.

Now we should have something like this:

This concludes the first episode. Congratulations, we have made a prototype of the game. There is very little left to do - turn it into a full-fledged game, which is what we will do in the following parts.

In this episode, we introduced the basic concepts of Game Maker, using as many features as possible. Some points were not made very rationally; they can and should be redone, but not all at once. For an initial understanding of what is happening, I think it is better to write in amateurish language.

As you can see from the lesson, in some respects the current version of Game Maker is not ideal, you have to keep a lot in your head, but in Game Maker it’s easier to do everything else. The slight inconvenience is worth it.

As promised, in this tutorial we will look at events, actions and create a couple of mini-games.
First the events. When something happens to the instances in the room, they are given permission to execute the event.

If you right-click on the middle column in the object properties and select Add event(add event) then the following window will pop up:

Create (Creation) - object creation event. It is triggered when an object appears in the room.
Destroy (destruction) - event of object destruction. It fires when we destroy an object with an action.
Alarm (Alarm clock, jargon. Alarm) - alarm event. Will be discussed later.
Step (Step) is an event that occurs every step in the game. The number of steps per second is set in the room settings
Collision (Collision) – an event that occurs when sprites (or rather masks) of two instances intersect
Keyboard (keyboard) - an event that occurs all the time while a certain key is pressed. It occurs for all instances at once, so it is very rare that the same keyboard events are delivered to different objects. There are also keyboard pressed and released events. They are convenient to use if an event must occur once (for example, a shot)
Mouse (mouse) – an event that occurs when you press/release/hover the mouse over an instance. There are also global mouse events that occur when the mouse is not hovering over an object.
Other events (other events):
Outside room (Outside the room) - The event occurs when the instance is outside the boundaries of the room.
Intersect boundary (Border crossing) - The event occurs when an instance crosses a room boundary.
Game start (Beginning of the game) - an event that occurs when the game starts. Rarely used in mini-games.
Game end (End of the game) - The event occurs when the game ends.
Room start (Start of the room) - This event occurs for all instances when the room starts.
Room end(End of the room): This event occurs for all instances when the room ends.
Animation end (End of animation) - the animation contains frames, and they are shown one after another. After being shown last frame the very first one is shown. At this moment this event occurs.
End of path (End of the road): Event occurs when the instance reaches the end of the path. You will read more about them in the following lessons.
User defined (Custom Events): There may be 16 such events. They won't happen unless you call them yourself using a special function.
Well, now the order of events:
-Begin step events ( Start of step events)
-Alarm events ( Timer Events)
-Keyboard ( Keyboard events)
-Mouse events ( Mouse Events)
-Normal step events ( Step Events)
-(setting all instances to their new positions)
-Collision events ( Collision Events)
-End step events ( End of step events)
-Drawing events ( Drawing Events)
Now we can supply events to the object, but why? For actions to be carried out.
Now let's look at the main actions of the movement:
Move Fixed (Fixed movement)
An action is used to give an object a specific direction and speed. The direction of movement can be specified by pressing the corresponding buttons. The middle button means stopping the object. The speed of movement is indicated in the corresponding line. If you select several directions, the direction of movement of the object will be chosen randomly from those marked. With this, for example, a monster can start moving both left and right.
Speed ​​Horizontal (Horizontal speed)
With this action, you can change the horizontal speed of the instance. Changes can be made relative (if you check the Relative box) or absolute (by default). Positive value moves the instance to the right, negative - to the left.
Speed ​​Vertical (Vertical speed)
Likewise, this action changes the vertical speed of the instance. Positive speed moves the instance down, negative speed moves it up
Reverse Horizontal (Expand horizontally)
This action reverses the horizontal speed. You can use this, for example, when an object needs to bounce off a wall.
Reverse Vertical (Expand vertically)
Likewise, with this action the vertical speed is reversed.
Jump to Position (Move to position)
This action moves the instance to the specified position. If you check the relative checkbox, the position will be selected depending on the current coordinates of the instance
Jump to Start (Move to start position)
This action will move the instance to the position where it was created.
Jump to Random (Move randomly)
The action moves the instance to a random point within the room, with a position chosen that is free of solid objects.
Bounce (Ricochet)
If you place this action in the event of a collision with a solid object, then it will bounce as in real life, without taking into account gravity according to the law "angle of incidence equal to angle reflections." In many cases this looks quite plausible.
We'll get to know the rest as we create mini-games.
So, let's begin!
The first thing you need to do is go to Game maker (where are we without the captain?). Now let's load the sprites: click on the Pac-Man image five times. Five windows with sprite properties will pop up in front of us. Let's load the files bomb, apple, wall, strawberry, banana from the sprites/tutorial1 folder and name them s_bomb, s_apple, s_wall, s_strawbery and s_banana, respectively.
/*And now some grammar. The names of sprites, sounds, objects and others must consist
only from Latin letters and symbols. Also, the name must be based on the principle
resource_name_note, example: s_hero_jump. It's immediately clear that this is a hero's jump sprite. */

Now let's create three sounds and load them from the sound/tutorial1 folder. Let's call them snd_click, snd_music, snd_boom. Let's do the same with the background.
Let's start creating objects. The first object is a wall. Let's call it o_wall and assign it the sprite s_wall. Now let's set its hardness (Solid checkbox). In the Create event, add the play sound snd_music action
The new object is o_apple. Let's assign the corresponding sprite to it and add the “Create” event. In it, select the “Move Fixed” action, set all directions except the central one and set the speed to 8. In the collision event with a wall object, set “Bounce”, and in the left mouse button event set Jump to random position, play sound snd_click and set_score with argument 50 and the “Relative” checkbox.

As a result, you should end up with something like this:


Now let’s create an o_strawbery object, assign a sprite to s_strawbery and do the same thing in events, only the movement speed will be 5 and the number of points will be 30.
Let's create an o_banana object, assign a sprite to it and make a copy of the o_apple object.

Let's change only Move Fixed this way:

And the number of points is 200.
Now let's create an o_bomb object and assign a sprite to it. In the “creation” event we will add an alarm clock (from the main2 menu), set the number of steps to 60. We will also add the Jump to random action. In the alarm0 event, add create instance and specify the bomb object. We will not change the coordinates; when the bomb is created, it will automatically jump to a random position. And finally, the left mouse button event. Action play sound s_boom, show highscore and game restart.

Now all that remains is to create a room and place objects in it, I did it like this:


Well, let's install a background in the room.
Now click F5 and enjoy the created “masterpiece”

Playing computer games is a lot of fun. But few people know that creating your own game is much more interesting. In the past, development computer games was a very long, complex and dreary process. Even now, games take months to create, and development teams consist of 20-100 people! But with the Game Maker program you can create your own game in a few evenings. Of course, you won't make Diablo IV, but there are simple games that are fun and interesting to play. Game maker is endowed with an instinctively understandable GUI, with which you can create good games without special knowledge of programming languages. It has a built-in GML language that expands the capabilities of your game, but more on that later.

Now we will get acquainted with the interface of the Game maker 8.0 program.


1. Line with file name, which you are working on, the version of Game Maker and the mode display (I have Simple mode)
2. Main menu. File group ( file):
2.1 New ( new) - Creates a new game file, completely empty
2.2 Open ( open) - open a previously saved file. You can open files of the current version, previous versions and backups (backup files). Opening files created in versions higher than yours is impossible2.3 Recent open (recently opened) - In this menu the program remembers recently open files for easy, quick access to them.
2.4 Save ( Save) - saves the changes made.
2.5 Save as... ( Save as...) - saves the changes made and allows you to change the file name and location
2.6 Create Executable... ( Create Executable...) - compiles the game in .exe format (separate application)
2.7 Merge Game... ( Connect game) - transfers the resources of one game to another (completely combines them).
2.8 Advanced Mode ( Advanced mode) -allows you to switch between easy and hard mode
2.9 Preference ( Settings) - allows you to change program settings
2.10 Exit ( Exit)
Apart from this menu, I think nothing else is needed (at least I have never opened them in 4 years)
3. Quick Access Toolbar. Contains the most frequently used menu items, such as create resource, open, save file, compile, run game.
4. Game resources. If you left-click on a resource, a menu for working with it will open. Let's take a closer look:
4.1 Sprites ( sprites) - pictures that are assigned to objects. A decent number of sprites come with Game Maker in the Sprites folder.
The interface for working with a sprite is simple - save, edit and its size:


4.2 Sounds ( sounds) - sound files, without which not a single game can do.
The interface here is almost the same: save, load and play:

4.3 Background"s ( backgrounds) - backgrounds in the game, then against the background of which the level’s action will take place. The interface is the same as in sprites.
4.4 Objects ( objects) - the main resource of Game Maker "a. You can add pictures and music to the game - but how to make the pictures move and the music play? Objects are responsible for this. They can move across the screen, collide, be created, destroyed. All of the above is events. During the occurrence of events, commands can be given to objects. For example: a player and a coin collide. The player is given a command to play the sound of the coin and destroy the coin. All that you will see moving in your games are objects (in fact, not quite everything, but about that much later).It is also necessary to understand the difference between an object and an instance. An object is an example. But it is not objects that are at play, but instances. exact copy object, only there can be a lot of such copies. When we talk about an instance, we mean one specific instance of an object. When we say object, we mean all instances of that object.
Click on the blue ball in the quick access toolbar(3)


The interface here is much more difficult than in sounds or pictures. On the left side there is a window for selecting a sprite, Visible items ( visible) and Solid ( solid). In the middle is a list of specified events. And on the right is a list of actions that are assigned to this event and a window for adding new actions. More about actions and events in the next lesson.
And finally, Rooms ( rooms). This is the place where backgrounds and objects are located - in a word, level. The first menu is the menu for adding objects. Everything is clear here - you click on an empty area, select an object and place it in the room. Installations follow. Here you can set the length, width of the room, as well as its speed and name. Next is the window responsible for backgrounds. Here you can select the background color in the room, or add a background that is already present in the project.

5. This Game maker"a working window

That's all. In the next lesson:
1. Events and the order of their execution.
2. Basic actions
3. Creating a mini-game "clicker"

In today's tutorial we'll look at the standard effects in Game Maker Studio 2. What they are, how to use them, and what pitfalls there are.

Continuing the course - Basics of creating games in Game Maker Studio 2

You can find the previous lesson here:

Don’t even dream about such things through standard effects :)

It is better not to use standard effects in GMS

Here we need to make an important digression. The default effects in Game Maker Studio 2 are not recommended for serious projects for a variety of reasons.

The main reason is that the effects are not very well optimized for performance. Standard effects can load the program (game) very heavily, since we don’t know how they perform, but apparently, they are not performed very well.

Standard effects are heavy, and I will also touch on the optimization and performance of games, but in the following videos and articles.

It is especially dangerous to shove all these effects into steps and if your game has a frame rate (FPS) of 50-100. The game will draw them 50-100 times per second, but what if you draw them for 100-200 objects at once? Of course, everything will hang here.

In general, game maker is quite easy to hang up, I made a bunch of games that hung up on my computer. For example, I made a virus simulator, and when the viruses multiplied greatly, they hung it up on me.

I pulled the GM for about 500 objects, then the FPS drops and the fan starts working so that the computer flies into the air.

Usually, you shouldn’t worry too much about optimization and performance of games if you are a beginner.

Often there are no problems with this since you make simple games, and everyone has powerful computers. But in general, and especially when you are making a game for phones, this point cannot be ignored.

Now I’ll just say this:

  • Avoid Transparency
  • Avoid big cards
  • Fewer functions in steps

Okay, that's what I said. Now, what effects are there in Game Maker and how to trigger them?

Types of standard effects in GMS and how to call them

3 functions available:

  • effect_create_above(kind, x, y, size, color); // create the effect OVER
  • effect_create_below(kind, x, y, size, color); // create a POD effect
  • effect_clear // clear and remove effects

I almost always use effect_create_above, although sometimes a different one is needed. For example, it is better to draw a pool of blood under an object, although it is better not to draw it at all...

kind- type of effect. More on this below.

x, y- it’s clear what it is, coordinates. Where we create the effect.

Read more about this here:

size- size. There can only be 0, 1 and 2.

  • 0 - small
  • 1 - medium
  • 2 - big


color- effect color. For example: c_red, c_blue, c_green

That's basically all, drawing them is very easy and there are usually no problems here. In general, since effects are a visual thing, the main problem here is visual things. That is, not how to draw them, but when, what kind and what color.

Views