Task 4 - Using a 2D Game Engine

2D Shooter Construction Log

To start my project, I opened up a new project in Construct 2 and I set the width to 480 and the height to 640.
Upon changing the Width and height of the project, I adjusted the project so that I could see the view point of the game. Upon doing so, I adjusted the layout size to 480 width and 640 height.



Upon doing so, the layout was adjusted to a suitable size for the game I plan to make. I then proceeded to create a variety of layers for my game. These layers consisted of 1 HUD layer, 1 Game layer, 1 Tile set layer, and 3 background layers.



I gridded the template, and added my first background on background layer 1. Upon doing so, I went onto background layer 2 and applied my second background. After that, I reduced the opacity of my second background to 60.





After that, I selected the tile set layer and I implemented my tile set. I then distributed the tile set around my level. They will be platforms in the full game.



Upon the implementation of my tile set, I began working on my vertical scroll and parallax. This allows the player to move freely around the map/level. The scroll acts as the games camera which allows for the player to see the main sprite when moved, and the parallax provides the behaviours that allow the main sprite to move in the first place.



As seen above, I gave the parallax the bullet and scroll to behaviours. This is because the player can move forward, which the bullet behaviour provides and the scroll to behaviour, gives the player freedom to move about freely. I implemented the scroll in the centre of the level, for the best view.




I then began to code the movement properly into the game. I began this by setting the player to move with the bullet vertically. I also set the player movement to scroll with Y to -306 and +306.




After sorting out the player movement, I then focused on the Player animation and the particle FX. I started to animate the player’s bank left and bank right into the game, via a sprite strip I had made in Unit 78.
As seen below, I have added in the frames for Bank Left



And for Bank Right



After adding the bank left and right animations to my player sprite, I focused on adding a ‘Burn’ effect from the submarines rear defences which I had created in Unit 78. The particle effect is as seen below.




After dealing with the animations and effects, I began working on my player sprites firing. I added in my player bullet sprite which was to be created when space bar is hit and would hit the enemies and ultimately destroy them. I however dealt with the hit points and the bullets doing damage, later in the process of making my 2D top down shooter.
As seen below, these are the events that I gave the game, in order to create the bullets on the layout on the layer GAME.



Upon setting the player bullet sprite to spawn upon the space bar being pressed, I then focused on the player fire rate. I made sure that the bullet was destroyed upon exiting the layout, and that the bullets had a sufficient cooldown time. All these events can be seen in the screenshot below



Upon that being sorted out, I started working on the weapon power up. The focus of this was to work with the power of the players weapons, and how many bullets where spawned upon the space bar being pressed.
The screenshot below shows the vast amount of events needed for the player bullets to spray.



I started off with setting the bullet angle of motion to not allow the player to ‘catch up’ with the bullets upon being fired. I also set the fire rate to a reasonable level, in order to prevent them from firing too quickly. Upon doing so, I copied and pasted these commands multiple times in order to conserve time. Upon copying and pasting multiple times, I changed the degrees slightly in each batch of events. Due to copying and pasting the spawn bullet events, my player sprite created a spread effect whenever pressing the space bar.
I then focused on creating the health bar. I added in a green rectangular strip into my game layout on the HUD layer. For extra aesthetic effect, I added it into a slightly bigger black rectangle.  This is seen below



I then added in the event that set the health bars width to the amount of player HP. This command is seen in the screenshot below.



The HP and MaxHP had been added in as variables prior to this event being implemented. I then started on working on an effect that adds different colours to the health bar when the players HP are at different points.




I created the effect to make the health bar green if the majority of HP is still there, yellow at most health lost, and red when health is nearly depleted. 


Upon the completion of my health bar and HUD, I began work on my first enemy's spawn spots and movement. 



I began sorting out the movement by by setting up the scroll and system to spawn the Enemy 1. I set it so that the Enemy 1 sprite is spawned at the start of the layout on layer 3 which is the game layer, and upon the spawning of the enemy, the spawn point is destroyed. I also set the bullet speed to 500 initially and the HasSpawned instance variable to true.

Upon doing that, I set the Enemy 1 animation speed to be 20, and upon doing so, set an event to create the Enemy 1 angle of motion in relation to the player. I then set the game to restart the layout upon the escape key being pressed.

In order to save memory, I set an event that destroyed the Enemy 1 if they exited the layout. All these events are displayed upon the above screen shot.

Once the movement and spawn points of the enemy 1 were completed, I then focused on the hit points of enemy 1.


I started by setting up an event that subtracted 1 point of hp if the player bullet collided with enemy 1. The overall hp of enemy 1 had been added as an instance variable prior to the screenshot. I then set an event up to destroy the player bullet upon collision with the Enemy 1 sprite. 

I then set about adding a brightness effect upon a collision  with the player bullet. I added the brightness parameters and upon doing so set the timer to play the effect upon a collision between the two sprites. To finish off, I set up an event to destroy Enemy 1 when its hp is set to 0.

When I had finished setting up the hp for Enemy 1, I then started setting up the enemy firing events.



I started by setting up the Enemy 1 line of sight and set the shoot variable to true. Upon doing that, I set up the events for the cool down and ammo for Enemy 1. I then set up an event to spawn the enemy bullet sprite from Enemy 1 on the game layer, and then set its angle of motion in relation to the Enemy 1 sprite. This is when I set the cool down to 0.

I then added delta time to to the cool down and then set up an event to subtract ammo when Enemy 1 spawns a bullet. To finish off the firing events, I set an event to destroy the enemy bullet when it is off screen to save memory.



Upon completion of this set of events, I started working on enemy destroyed effect. I started this by setting both blood effect 1 and 2 to spawn upon the destruction of Enemy 1. The events neede for this are seen in the screen shot above.

After this was taken care off, I began working on the audio for the player gun and the enemy fire damage.


I added the sound effect 'Weapon sounds' to play whenever the fire button for my player is pressed. Once this was sorted, I focused on the player hit points in order to set up the damage taken from  enemy fire. I started off by setting the width of the player health bar when it reaches certain damage levels.

I then set up the event that puts the player hp to max upon the start of the layout. It was then i set up the damage for when the Enemy 1 and Player sprites collide. I repeated the same method of setting the brightness effect upon collision, but put the event of a direct collision to take away all player hp rather than just one point.

I then set up the event to destroy the player upon its hp being set to 0. I repeated the brightness effect in this situation as well.




Upon doing this I set up the collision masks for my ammunition types. The collision masks are seen in the screen shots above.

When that was completed, I began working on the Misc enemy launcher. This particular aspect of the game was the lengthiest section of event in the 2d game as off that stage.



I began by setting the misc enemy to spawn from a pod that would be displayed on screen, opposed to being hidden like the Enemy 1 launchers. I also added in a bulge effect to make the launchers look like living creatures themselves.

Upon doing that, I set up an event to spawn the pod/launchers on the game layer, and for the misc enemy spawner to be destroyed upon the spawning of a pod. I then set another parameter for the bulge effect. I then sorted out the cool down and ammo events for the misc enemy launcher. This involved setting out the angle of motion and acceleration and to set a timer for a self destruct feature for my spawner. I also set up events to spawn the misc enemy themselves and the cool down for when they spawn.

Upon sorting that out, I  set the hp up for the misc enemy and set an event to subtract hp when the player bullet collides with an misc enemy. I set up a destruction event for when their hp is set to 0,. and a brightness effect upon collision. Upon the hp of the misc enemy being set to 0, the blood effect would be shown.

The misc enemy was also given a timer. Upon a certain time passing, the misc enemy would self destruct which was needed, due to the fact they spawn in large groups.

Once the misc enemy events were completed, I began working on my enemy 2 events.




I started enemy 2 by setting up an event to spawn it on the game layer. Upon doing this, I set the scale of the enemy 2 and the turret that would be attached to it, in order to fire bullets at the player. This was achieved by giving the turret a pin behaviour and setting up an event to pin the turret to enemy 2.

I gave the turret events to aim at the player sprite but to also set it as disabled initially after being spawned. I gave the enemy 2 a bullet behaviour, which I then set the speed and acceleration for. The goal of these events were to have the enemy 2 fly alongside the player and to try and deal damage to the player consistently across the entire level.

I set the enemy 2 and turret sprites to self scale upon being spawned. I then set up sine behaviors for enemy 2 and set their magnitude and and their active status. I then began working on setting the spawn events for the bullets that would fire from the turret on enemy 2. I set up the angle of motion of the bullets, their ammo and their spawn events.

I set up the hp for enemy 2 and for the enemy 2 sprite to take damage upon collision with the player bullet. Upon the destruction of player 2, the same blood and brightness effects would play that are found elsewhere within the game events.

After I completed the events for enemy 2, I began work on the level boss.




I began the events of the level boss by pinning the sprites boss movement and boss turret onto the boss sprite. Boss movement is the animation on my boss sprite for when the missiles fire and the boss turrets are to fire regular bullets at the player.

Events where then added to play the animations for firing the missiles and the bullets via the boss movement and boss turret sprites respectively. The turrets were given events to acquire the player as a target and for the turrets to spawn the bullets needed to harm the player.

The boss movement was given the brightness effect for whenever they are hit by the player bullet, and the boss would be defeated when the movement sprite was destroyed. Upon destruction, blood would be created and then displayed on screen.

Upon finishing the boss events, I moved on to the boss sound effects, damage to the player from the boss and the layout change.

 I started off by setting a timer to end the level upon the bosses destruction. I then created a new layout without an events sheet called Level 2. I then set an event to go to Level 2 upon the end of the level timer finishing.



Upon doing that, I set the player to take damage from the level boss. I started by setting up events for the missile sprite to take hp from the player sprite upon collision. I did the same with the level boss sprite itself.

I then focused on creating a scoring system for my game. I began this by adding a global variable called score. Upon doing so, I added in a text sprite into my HUD which would display the score onscreen during game play.

After doing this, I began to add score options to my enemies, so upon their death, the score is increased. I gave the player more points depending on how hard the enemy is.


Upon finishing the Score System, I began working on adding power ups into my game.

I did this by creating spawners for my power ups and setting events to spawn my power ups at the spawner sprites, which would then be destroyed upon doing that. I then set events, so that my player character regained max health upon collision with the health power ups and increased bullet fire upon collision with the weapon power up.