Chapter 6. Making a Tower Defense Game

Tower defense games are fun to play and (somewhat) easy to develop. Construct 2 can develop a tower defense game much more easily than if you were to code it by yourself. Before we start, if you haven't played a tower defense game before, you should go and try one to get familiar with the genre. A Google search for tower defense game should bring up lots of options for you to try. A tower defense game is where you set up defensive towers that protect an object from enemies. These enemies usually come in waves and when they are destroyed, the user gets some currency to buy more towers or to upgrade them. In this chapter, we will learn the following:

  • How to start a new project
  • How to add a turret
  • How to add tower defense game logic

Starting the project

First we need to start a new project and set the Layout Size option to 640, 480 in the Layout properties panel. We do not need to have a bigger screen size for this project. Generally, for smaller web games, it's good to have this resolution as most players are used to seeing it. You can make it bigger if you want to, but this is the more standard resolution that developers use. It should look like the following screenshot:

Starting the project

Once you have completed the setup, go ahead and add a background. The background should be 640, 480. When you create art in a different program, you should make it in the same dimensions you are using in the game. You will rarely need to do a lot of resizing in the game. The following screenshot shows the background design:

Starting the project

Once you have set the background, change the layer. Change the current layer's name by selecting it and pressing F2. Change it to something such as Background, as shown in the following screenshot:

Starting the project

Once you have completed the previous step, lock the layer. Create a new layer to which we can add the game objects, as shown in the following screenshot:

Starting the project

The next thing we need to do is set up Snap to grid. By doing so, our turrets can snap to the grid. Click on the View tab at the top of the screen. It is shown in the following screenshot. Once you are there, select the Snap to grid checkbox.

Starting the project

Doing so will snap any object to the grid of 32 by 32 pixels. You can change the grid size, but make sure that the grid size can be divided with the numbers of our screen resolution (which is 640 by 480). The current grid size, 32 by 32, does divide evenly between these two numbers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.85.181