**This is an old revision of the document!**

Tank shooter - Beginner tutorial

This tutorial will help you to get familiar with the way that GDevelop works. You will create a very simple game. In this game, the enemies will move toward the player. The player will be able to shoot the enemies. The enemies will explode when they are hit with the player's bullets.

To get an overview of the software I recommend that you read the Getting Started page first.

Download GDevelop

If you do not have GDevelop, download it from the official website : gdevelop-app.com

Always download GD from this page to be sure that you have the latest version. Once you have installed GDevelop, launch it. The Interface's “Start” page will be displayed:

Download the source

You can download the finished project from here beginner-tutorial.zip . Downloading the finished project helps you to see how the game has been created. Having it as an example in case you get stuck or don't understand something, is a good way to to check your progress.

Create a new project

Click “Create New Project” on the “Start” page.

Next, you have the option to create a new project using a template or create an “Empty game” project.

For this tutorial, you need an empty game project but before selecting this option, you need to choose a folder where your game will be saved. On the bottom of the “Create a new game” page you will find the “Choose Folder” area. You may need to scroll down to see this option. Keep the default location or select the location where you'd like to save your game.

To select a custom location, select/click the “Choose Folder” button. Browse the file system on your computer. Locate the folder that you want to use.

Once you have a folder selected, select/click the blank “Empty Game” project option in the list.

Create a new scene

Creating a new scene is first on your list of things to do. Click/select the “Click to add a scene” button in the Project manager:

Next, click on the NewScene you have just created. It will open the “Scene” editor.

Get the images and resources

Before going further, you will need some images for the game. You can download them here : Download images

Once you have downloaded this file, extract its content into the folder where you created the project.

Create the player turret

The player will be controlling a turret to shoot the enemies. In the Scene “Objects” editor choose “Add a new object”. A new window list of options will popup. Choose the type of the object that will be created.

First, create a sprite object. Select “Sprite” from the popup list. Next, the object properties panel will be displayed. If you don't see the properties panel, right click on the NewObject in the Object editor and select “Edit object” from the popup list there.

Finally, we want to add an animation to the object. Click/select the “add animation” button in the properties window.

You will now see the animation properties of the object.

You need to add the turret image as an animation. Click the big plus symbol . Browse to the project folder. Find the image aaguntopdown.png. The image will be displayed in the window.

Lastly, click “Apply” to save the changes.

Rename the object. Right click on the turret object in the Scene “Object” editor. Select “Rename” from the popup list that is displayed. Type the name “turret” for the new name. This allows us to later refer to this object using the name “turret”.

Add turret to the scene

To add the “turret” to the scene, select/click the turret in the Scene “Object” editor then click in the “Scene” editor. This action will create a “turret” in the scene. The “turret” can then be selected, moved around and rotated.

First events

We are now going to create the “Events” used to animate the entire game. In the first event, the “turret” must be rotated toward the player's mouse.

Select the “Events” editor by clicking on the “ NEWSCENE (EVENTS)” tab:

You will see a toolbar on the top of the “Events” editor screen. Select/click the “Add event” button on the toolbar to create a new event. If you forget how each tool on the toolbar is used, hover your mouse over the tool image to see a popup help description for the tool.

The new “Event” is created, with an empty condition and an empty action. The “condition” is located on the left side of the screen. The “action” is located on the right side of the screen. Put your cursor over the “action” on the right. Select/click “add action”:

Now, you are going to write your first action. This action will turn the “turret” toward the mouse. After click/selecting the “Add Action”, a new list panel will appear. Choose the action “Common action for all objects”. A drop down list of more options will appear. Select/click “Angle”. Another drop down list will be shown. Select/click “Rotate toward the position”. When “Rotate toward the position” is selected, another list of choices will open on the right side of the selector panel. It displays the name of the action as well as the parameters for the action. Fill in the first parameter by select/clicking on “Object”. “turret” will popup from a list of the available objects. Select “turret” from the list. For the next parameters, enter MouseX() and MouseY() so that the object turns toward the mouse position. When the game is launched, these two expressions will get the current X and Y position of the mouse. For the “angular speed”, enter 0. “Angular speed 0” means that immediate rotation of your object will occur. That is what we need to rotate the “turret”. To control the speed of the rotation of an object, enter a smaller value for “angular speed”. For example, to slow your “turret” object down, enter something like a value of 100.

At this point the parameters of this event will look like this:

We have been using expressions to get the X and Y positions of the mouse. You can find more expressions in the “expression” editor by clicking on the blue icon next to the value fields:

When you click the “expression” editor icon, you can search for all of the available expressions. The expressions are sorted into categories.

To save the changes that you have made to the “expression” editor , select/click the “OK” button that is located on the bottom right corner of the panel.

Now you can run a preview by pressing the “preview” button on the toolbar located above the Scene.

The “turret” will now rotate toward the position of the mouse. If the rotation isn't working, look closely at the above steps again or refer to the finished tutorial.

Shoot bullets with the turret

We want the player to be able to shoot bullets at the enemies. To set this up, you will need a new “bullet” object. In the Scene “Objects” list located on the right side of the GD interface, mouse click on the “turret” object. Choose “add a new object” or, alternatively, mouse click the “add new object” button. Choose “Sprite” from the popup list panel. Now, add an animation by selecting the add button. Choose the “Bullet.png” image. Rename the new object “bullet”. If you need additional help adding a new object, refer to the “turret” object explanation above.

The next event needed will check to see if the left mouse button is clicked/pressed. If it is pressed/clicked, the action will create the bullets that will be fired. To create the bullets, go to the “NEWSCENE (EVENTS)” tab. Add a new event. Again, if you need additional help, refer to the “turret” event above. “Create a new object” will be the first action in event. This action is available in the “Common actions for all objects” “Objects” panel.

When “Create a new object” is selected, another list of choices will open on the right side of the selector panel. It displays the name of the action as well as the parameters for the action. Fill in the first parameter by select/clicking on “Object”.“bullet” will popup from a list of the available objects. Select “bullet” from the list.

Since there is only one layer in the game, the layer parameter is not required. Click on Ok to finalize the action.

Then add another action after this first action. Do not create another event. Click “Add action” below the first action!

This time, choose the action called “Common action for all objects” “Movement”

> "Add a force ( Angle )".

GDevelop provides a built-in forces system. This system allows you to easily move the game objects. In our case, when the bullet is fired, the action will be used to move the bullet toward the mouse. As the first parameter(Object), enter “bullet” so that GDevelop will move the bullet just created in the previous action.

For the “Angle of movement”, we'll put the same angle as the turrent. Enter “turret.Angle()” in the 2nd parameter. For the 3rd parameter, enter “400”. The bullet will move with a speed of 400 pixels per seconds. Finally, click on the “Permanent” option. This last parameter tells to the force to be constantly applied to the bullet. After the movement is started, this parameter keeps the bullet moving.

Our two actions are launched when the player is firing. i.e: Pressing the left button of the mouse. To create this event in the “Event” editor, we need to add a condition to the event, click/ select “Add condition”.

Choose the condition “Mouse and touch” “Mouse button pressed or touch held”. On the right side panel popup, click the Button to test parameter. Select “Left” from the list Finally, close the window by clicking the “OK” button. The condition is now added to the event.

If you preview the game now, you'll see that we have two problems:

  • The bullets are fired too fast.
  • The bullets appear at the object's origin. This makes the bullets seem unrealistic.

To address the first issue of the bullets firing too fast, we are going to use a timer. Add a second condition to the last event we've created. Choose the condition“Common conditions for all objects” “Timers” “Value of a timer”. The panel appears on the right. The first parameter, “Object”, indicates the name of the object. Leave it blank. The second parameter,“Timer's name”, is the name of the timer. Enter “firerate . Do not forget the quotes around the timer's name! Enter 0.25 in the third parameter, “Time in seconds”.

We aren't done yet! We want to shoot bullets every 0.25 seconds. To do that, we need to reset the timer to start from 0 after 0.25 seconds. So let's add an action: “Timers and time” “Reset a timer”. This action will be placed just below our “movement” action in the same event. Enter “firerate” as the parameter which is the name of our timer ( again, be aware of the quotes! ). This pair of conditions and actions will ensure that the actions used to fire the bullet are repeated when at least 0.25 seconds have elapsed since the last bullet was created.

We must now set up the way that the bullets are fired from the canon of the turret.

In order to do that, we are going to add a custom point to our “turret” object. We then create the bullets in the position of that point. Let's open the object properties by right-clicking the “turret” object on the right side of the Scene Interface screen. Select Edit object from the popup list. This selection brings up the window where we add animations to our objects. We will see a button called “EDIT POINTS”.

After clicking the button, we can see that our object currently has 2 points by default, the “Origin” point, and the “Centre” Point. We can not rename these points but we can change their default position. In this case, we will add one more point to the object.

Let's click the “add” button (plus symbol) to add a custom point to our “turret” object. We immediately see the new point added to the list. It can be identified by the name “Point” and position 0,0. Let's rename this point to “Canon” and set the X position to be 110 and the Y position to be 35

Now, when we preview the game, we will see our custom point located at the end of our canon Close the window and apply the changes.

The only thing is left to do is to tell GDevelop to fire the bullets from the “Canon” point of the “turret” object. So in our “create bullet” action, we need to change turret.X() and turret.Y() expressions, to turret.PointX(Canon) and turret.PointY(Canon). We can change them by clicking the expressions inside the editor. Don't forget the capital C in Canon as the name of the points are case sensitive.

If we run the preview now, our bullets should be fired from the 'Canon“ of the “turret” but you may notice,at times, the bullet is a bit offset. This happens because the origin point of the bullet is at the top left corner. The same way we did with the Canon point for the turret, change the position of the Origin point of the bullet to be in the middle.