Construct 2 Game Creation: Part III more Space Chain


This post will continue the series about Scirra’s Construct 2. You can check the 1st post here and the 2nd post here.

In the second post we checked the basics of the enemies in Space Chain, a starter kit that you can download here. You can also get it and play it at the Windows Store and check the Windows Phone version too. 

And you can play it here too: 

 

 

 

 

Overview

 

This same section was included in the first post, so if you read that one just skip it. Or go back and check how to set up your project and how enemies work.

In Space Chain the player should destroy the falling enemies before they touch Earth. The control input relies heavily on Construct's capabilities and allows the player destroy the enemies using their mouse or the touch screen when available.

To obtain more points the player could destroy enemies of the same type and create chains. That is also the origin of the game's title.

The purpose of this Starter Kit was to provide a base showcasing the basic controls for sprites in Construct 2 and elements commonly used in games like a score, a pause button, game over conditions and global variables.

This starter kit was also a good example on how to take a Construct 2 game and publish it in the Windows Store.

In future  posts we will study more complex examples and how to port these games to Windows Phone.

Dude, where is my Input?

With the events we studied in the previous post you would have 4 kinds of monsters that appear at the top of the screen and fall down to crash against the sprite that represents Earth, but at no point we are detecting any action from the player.

The first step to make this a real game is to detect where the player is touching the screen, or where he is clicking. With other platforms you would have to write code to detect the 2 different inputs but in Construct 2 the Touch Object brings all that functionality in one neat plugin.

To include the Touch Object you have to double click anywhere in your layout and select from the following menu:

By default the Touch Object will detect the mouse input too, but you can change this using its properties:

And the cool part is that this plugin  will still work In devices that do not support touch input, and will offer mouse detection without a problem.

After including this plugin we can ask where in the screen is the player touching or clicking or, even better, if the player is touching a particular object.

In Space Chain we are interested to know when the player is touching any monster, to destroy it and check if he is creating a new chain of destruction.

I included four events that follow the same pattern shown in the previous picture, one for every kind of monster.

In this event Construct 2 is checking if the player is touching or clicking on ANY of the orange monsters and if the game is not paused (more on that below). If these two conditions are met we create a new explosion, destroy the monster and augment the score.

 

In Space Chain the other main input detected from the player is when the game is over and he wants to restart it. To do this we display a Game Over Text and when the player touches or click this text we restart the game with the following event:

Most of the actions performed in this event take care of resetting the global variables used in the game. The third action, Go To Layer 1, is the one that restarts the layer and the game. In future posts we will see more complex games that have more layers and use extensively this action.

Add some Pause and Cool down your Jets

In a game as simple as Space Chain, the third main interaction we will have with the player is the Pause. The player should be able to Pause and continue his game at any moment, to do that I added a button that will take care of the Time Scale, that is the System attribute that determines how fast the game cycle is running, and if we set it to 0 the game will be complete stopped.

To make the Pause work like an on/off switch, I added a global variable creatively named Pause. This is variable has a value of 1 when the game is paused and 0 when it is not.

With the event represented in the previous picture we are detecting every time the player clicks on the PauseButton, but this also works when the player is using the touch controls. 

To ensure that the value of the Pause variable is always 0 or 1 we have to add this event:

And to set the proper Time Scale and display the correct label in the PauseButton we have to add these 2 events:

If you want to play a little more with the Time Scale attribute you could add bullet time effects to your game or speed up the flow of your game. In this starter kit is only used for the pause functionality, but it has an incredible potential in many kinds of games.

 

And what about the Chains??

This starter kit is named Space Chain because we are detecting if the player is destroying consecutively monsters of the same type (that is why every type has such distinctive colors). 

To be able to detect chains of destruction I added two Global variables named LastDestroyed and ChainNumber. The first one keeps track of the type of the last destroyed monster, and the second one the number of monsters of the same kind that have been destroyed any given moment. Both Variables should be initialized at 0.

In the events that detect the user touching any of the monsters (detailed in the previous section) we add 2 sub-events (right click on the event and then add, sub event). These sub events decide if the player touched the same kind of monster as before and augment the chain, or if he touched another kind of monster. As you may see in the project the 4 kinds of monsters are numbered (SBlue=1, SOrange=2, SRed=3, SPurple=4) and this value is the same I am saving in LastDestroyed every time the player touches a new monster.

You may also note that the Score gets a larger bonus when the chain is bigger, you can modify these events to tweak the points you give the player.

The other actions performed in these events have to do with showing the player the increased bonus when he creates longer chains.

 

To be Continued

In the following post we will give the final touches to the project and will discuss the possible modifications that you can make to create your own games. And after that I will be posting how to export and submit this game to the Windows Store. In the meantime play the game and let me know what you think of this starter kit.

Comments (0)

Skip to main content