For more developer tutorials and news from Android Authority, sign up below! Layer order is actually defined by a value, called the "depth" value. But what isa layer? So, add a Create Eventnow, and in the action editor window that pops up drag the Assign Variableaction and set it to the following: This gives us an instance variable with the name "thescore" and sets its value to 0. We want to set the colour that the font is drawn in too, so now add the action Set Draw Colourlike this: The default colour is white, so we don't need to change anything there (although you could set the colour to anything you want by clicking the colour swatch in the action which will open a colour picker for you or by giving a hexadecimal colour value), but we need to un-tick the "Use alpha from colour" option, as we want the text to be drawn solid white regardless. We have set the direction so now we use this action to set the speed to 16, which means it will move 16 pixels in the given direction every game frame. obj_damage With this action, we check to see if there is an instance of the player object in the game room because later we want to access certain variables from that instance. We are going to place this action into the enemy object obj_enemy, specifically in the Step Event, just before we destroy the instance. . The idea behind an object is to create a kind of blueprint of behaviours that can then be used within a game. GameMaker Studio 2 - Drag and Drop - YouTube We want to change this so that the Assign Variable action will only be called if a key is pressed so now we need to drag it onto the right hand side of the if keyboard downaction like this: Now what we have is the "if" checking for a key and only if it returns true (the key is being held down) will it run the assign variable action. You've come a long way from knowing nothing to creating something that is actually interactive - if not quite a game yet - and have learned the basics of how to use GameMaker Studio 2. To do that open the room resource (double click on it in the resource tree), and then drag an instance of the object obj_scoreinto the room and place it anywhere (make sure that you have selected the "Instances" layer first). free game engines This is a verybasic mechanic and we'll refine it more in later However, Ive found that visual coding languages like Drag and Drop tend to hold back developers that would be better off just buckling down and learning code. With a simple idea in mind, its time to section First Before we end this tutorial, let's quickly add in a collision for the player colliding with the enemy. download it here Your character should be able to move left now. Finally we set the sprite rotation (image_angle) to face the same way as the direction variable. Scale Image drop-down in the resources panel and click Right now, unfortunately, our player object looks like nothing. Objects To navigate the workspace, use the scroll wheel to scroll or the middle mouse button to move around. Go ahead and drag the Declare Tempaction into the general Draw Event action workspace now and fill in the following: Here we are getting the ID value for the camera assigned to view port[0] using the built-in global scope array view_camera, and then storing it in the temporary variable "vc". Simply go to the Resource Treeand right click on the Soundresource and click Create. When you drop the sprite in, you should see it automatically open up in a separate window for closer inspection. are what they sound like: places for you to put your sprites and game objects. Currently the player instance is on the "Instances" layer, and we need to add a new layer for our bullets, so click the New Instance Layerbutton to create a new layer and name it "BulletsLayer" (to rename a layer, simply slow-click twice on it). We want to be able to walk left and right and jump up in the air. Jump is slightly different. Objects In the next We can do this with a second I'm no programmer at all, so I would need to use the drag & drop mode. For that we need to add a Key Up Event. Run your game again (press ) and this time the player instance should do nothing unless you press the right arrow key. Now that we can move, lets make something that can hurt us, to provide a bit of a challenge for our players. So we can't write: That code will subtract 1 from ANY of the instances of "obj_enemy" in the room, and so is best used when we know that there is only one unique instance to be accessed. You don't even have to worry about placing it properly because we've taken care of that in the Create Event of the object. To answer that we need to back to the Sprite Editorand explain another of its features - the ability to set up a collision mask. we will change that by making it more attractive to the player using tilesand also expand the play area using cameras. Once you have named the resource and added the file, you can use the audio preview buttons in the editor to listen to the sound and set its volume: The rest of the options here we can leave at their default values, but if you want to find out more about them then hit to open the manual and go to the section on the Sound Editor. Were going to use the one we just made. on the Add Eventbutton: In the image above you will see that we have highlighted the "Step" category, and within that the general Step Event, as this is what want to add to our object. In this case we are going to change the alpha to make the sprite "invisible" at the start of the room. Otherwise the G-forces would prevent our player from being able to move! Let us know what you think of GameMaker Studio in the comments below, and if you would like to see a tutorial for GameMaker Language in future. we'll expand on what you've learned here by adding bullets and other world items into our Arena Shooter game. Note that actions are added in a linear fashion, so each subsequent action that you add will be added afterthe previous. We now want to add "spread" to the bullets so we use this action along with the function random_range to add or subtract up to 4 to the direction. However, if you have zero coding experience, you should still be able to follow along. Next we need to add a Step Eventwith the following actions: All this action block is going to do is add a small amount to the image_alpha value and then check it to see if it is over 1, and if it is it resets it to 1. All this will do is stretch the background image used to fill the whole room area, which with a small image like the one we are using doesn't look right, which is why we tile it instead. This grid shows the way that the image will be split to create the final tile set cells, and if you have used the tutorial image you can probably tell that the current settings are way to small for the image we are using. : Hopefully when you look at that list you can feel proud of yourself. Right now, nothing happens; weve got a bit further to go before this GameMaker Studio tutorial is through! Drag and Drop is simply more work for less functionality, so well be sticking with GML for this tutorial. A Note About Game Engines Not assigning a sprite to an object means that when we run our game with an instance of that object in a room it will not be drawn, but that doesn't mean that it isn't doing anything. The videos that accompany each In this . You can now add the Set Instance Rotationaction below (from the Instancesaction library), and set it to use the local variable "dir" to set the rotation of the image_angle: If you run the game one more time now, you should see that the player instance moves around and that it turns to follow the mouse: The first section of this tutorial is now complete, and you have the player moving around and you have their "ship" turning towards the mouse ready to start shooting!