Tower Defense for the free version of Construct 2

2

Tagged

Attached Files

The following files have been attached to this tutorial:

.capx

tower-defense-demo-final.capx

Download now 31 MB

Stats

1,430 visits, 2,111 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

The tutorial is designed to be used for the free version of Construct 2. It is designed so that towers can be added without adding new events. Each tower has some variables in addition to the variables it has when the turret behavior is added to it:

Bursts:

-The amount of times it shoots during the “on turret shoot” action.

Current Bursts

-The current burst that the tower is shooting. This is reset, and should not be modified.

Shooting

-This is another variable that should not be modified.

Burst wait

-The amount of time between each burst. This must be lower than the rate of fire for the tower.

Damage

-The amount of damage that the tower will do to enemies. Splash damage will do 50% of the damage value.

Inaccuracy

-The maximum rotation, in degrees, that the towers projectiles can rotate clockwise, or anticlockwise.

Spread

-The amount of bullets that will be shot on either side of the initial bullet. (The pictures below may help)

This picture has the value at 0.

This picture has the value at 1.

This picture shows the value at 2.

Spread Angle

-The amount (in degrees) that each additional spread shot will rotate.

Splash

-The scale of any splash damage from the tower’s bullets.

Seeking

-The amount (in degrees) that bullets from the tower will rotate every 60th of a second.

Speed

-The speed of bullets from the tower.

Money

-The amount of money that the tower will cost to be bought. Upgrade costs are based on this value.

Type

-The name of the tower, for example, Cannon.

Sprayer

-A variable that should not be modified.

Frame

-The animation frame that the tower will use. The upgrade will be the next frames.

Max Ups

-The maximum amount of upgrades the tower can have. The value for this variable should be the desired amount of upgrades minus 0.5

Image Point Addition

-The image point from which the tower shoots bullets will be increased by this value during each burst. It is only used for multi-barreled tower, in any other case this should be set to 0.

Current image point

-Another variable that should not be modified.

Burst wait addition

-The amount of seconds that is added to the burst speed variable during each upgrade.

Slow percentage

-The amount, as a percentage, of speed that enemies will have when the are hit by bullets from the tower. 100 will not cause a change of speed, 0 will freeze enemies. It is believed that the freez mechanic has caused a bug, so the events regarding it are bookmarked if you want to delete them.

Slow time

-The amount, in seconds, of time that enemies will be slowed for when they are hit with bullets from the tower.

Bullet Frame

-The animation frame for the bullet. The trail for the bullet will use the same frame number.

Spread multiplies

-The amount that the spread variable will be multiplied by and the spread angle value will be divided by during an upgrade.

Range

-The amount, in pixels, that bullets from the tower will travel before starting to fade,

Fade

-The amount, in second, that bullets from the tower will take to fade out completely after the have exceeded their range.

Hit Fade

-The amount of time (in seconds) that it will take bullets from the tower to fade out completely after hitting enemies.

Powpacity

-The opacity, between 1 and 10, of explosion effects from the tower’s bullets.

Zapacity

-The opacity, between 1 and 10, of shock effects from the tower’s bullets.

Sound

-The sound that the tower will make when it fires.

All of the variable are decided by the Button sprite, which has the above variables. When the button sprite is clicked and the amount of money the player has is greater than the cost variable of the button, a new tower is created. The tower sets the values of it’s variable to the values of the corresponding button variables. This is shown in the events pictured below.

The events in the picture below show how the spread variable works. Instead of using the variables in the game, this code uses set numbers. In the picture, the number 2 in event 13 would be replaced with tower.spread and second and fourth actions of event 13 with tower.spreadangle*variable1.

The events in the picture below would be used to enable towers to shoot in bursts.

The events in picture 7 make seeking bullets follow enemies and make bullets create a trail effect. The bullet 2 sprite has the fade behavior and has the image of the desired trail. The trail effect is fairly easy to do and looks more interesting than just having a bullet. The difference is shown below the picture of the events (shown in the pictures below).

With trail effect ^

Without trail effect ^

The enemy spawning system is designed so that each wave can be modified. Enemies come from spawner sprites (title “spawner”). Each sprite has a few variables:

Round

-This determines when the spawner will be active.

Time

-The time between each spawn.

Speed

-The speed of enemies that it spawns, in pixels per second.

Animation

-The animation that enemies spawned by the tower will have, for example, “Animation2”.

Health

-The health that the enemies will have when created.

Coins

-The amount of coins that the enemies will create when they are destroyed.

Offset

-This variable should not be modified

Immune

-Whether or not the enemy is immune to freezing.

Each time the “Go!” button is clicked, the round number, which is a global variable) is increased. The first spawner should have its round number set to 0.

In the level select screen, there are multiple yellow-orange rectangles. The are buttons. They have a few variable:

Layout

-The layout (by name) that they will go to when clicked.

Level

-The level that the player must be at to use the button.

Name

-The text that will appear on the button, for example, “Level 2”.

At the bottom of the level select screen are colored buttons. Clicking them will change the music in the game. Their variable should be the name of the sound file that they should play.

Thanks for viewing the tutorial. Please ask any questions you have about the tutorial. If you use the tutorial to make a game, please tell me. Thanks for viewing the tutorial.

.CAPX

tower-defense-demo-final.capx

Download now 31 MB
  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!