Task 4 Using a 2D Game Engine

1: Set Up
First I created a new empty project which then I then changed the window size And then changed the layout height and width to 480x 3200. So it changes the layout of the to a vertical scrolling game.
Once done I added several layers and renamed them and organised them in the right order. 

2: Tiled Backgrounds I used the layers BG1 and BG2 for setting up my background I did this because I was having two different layers for the background. For instance on BG1 I clicked on insert new object, clicked tiled background and then choose my background PNG which then I adjusted to fit the length and width off my project window size. Once done I locked that project and then began on BG2. Background 2 was for my clouds so I did the same that I did for BG1 but adjusted the opacity and changed the blend mode to additive to give it more of a cloud effect.  

3: TILE MAP


For the tile map I inserted a new object and then picked inset a new tile map. I then uploaded my tile map png and used the tile map option to create/add new boxes onto my project. This allowed me to create platforms in many different shapes and sizes.



4: Vertical scroller & Parallax
I made sure the layers BG1, BG2 and tile set was locked so I could then place a new sprite which was going to be my vertical scroller. To make this sprite a vertical scroller I added a few behaviours to it. Firstly I made sure the sprite was just an ordinary box and I then added the behaviour of bullet which made the sprite move up in the game however this was too fast and the camera wasn’t fixed onto the sprite. So I adjusted the vertical scroller speed to 30 and then added another behaviour which is called ‘scroll to’. Once this was done I then adjusted the parallax of the layout BG1 and BG2 although I made BG2 Faster to give more of a moving effect.






5: Player sprite and movement
On the game layer I added a new asset which I renamed the player. In the asset I imported three different animation key frames such as the flashing lights and the left and right turning of the player. Once The animation frames was in the correct place I adjusted the playback and turned on loop. This basically made sure the animation was playing over and over at a certain speed; the speed I used was 24. Once I was happy enough with the speed of the animation I rotated my player’s animation clockwise within the ‘edit image’ doing this corrected the player’s origin position.

The next thing I did to the player asset was add two different behaviours for instance these two behaviours was called the bullet behaviour and the custom movement behaviour. The bullet behaviour is a behaviour which allows the player to move in 8 different directions although in the behaviour priorities section I changed the ‘8 direction’ to the 4 direction this allows my player to move up, down, left and right which is the most suitable for my top down shooter game.
For the custom movement I went into the event sheet and edited the custom movements to set the vertical speed same as the scroll asset speed. I did this by creating an even which was system every tick and then creating an condition and going into the players custom movements and setting the speed to ‘vertical’ to ‘scroll.bullet.speed’ this basically means that the scroll will be the bullets speed every frame. I also made sure the angle of motion is the same so I created an new condition and going into player to custom movements and into sent angle to ‘scroll.bullet.angle.’ this makes our player fly in the same angle the bullet does.
Next I limited where the player could go for example I made sure the player couldn’t fly off the screen by going to far up, down, left or right. I did this by comparing the players X and Y for example Set Y to scroll.Y+306 and the same as the X scroller. This stopped the player from flying off left, right and top and bottom.






6: Player animation and particle  FX
I added the animation key strips previously and now I am going to set the animation so the animation will play when the button is pressed for example for the bank right I went into the events section and created a new event which was ‘when right is pressed down’ and then set a condition which said ‘set animation to right’ and then made an event  which gave the command that once the right key button was unpressed the player will go back to default. This makes the player looks like it is turning when pressed, I did the same to the bank left animation.
Afterwards I imported the particle asset and imported my burn png file which then I adjusted to give it more of an burning appearance e.g I adjusted the blend mode, play rate etc. Once I was happy with the flams I added the image points to all of my animations and started to put the burn commands into the event sheet. I did this by creating an new event and basically put when the up key is pressed the system has to create the particle object.





7: Player bullets
For this section I added the player bullets. I did this by creating an new object and importing my player bullets png which then I added the behavior bullet to the sprite and added some events within the event sheet. I put in the codes to basically tell construct that when the space bar is pressed the system has to create the player bullet on layer 3 which is the game layer. However I didn’t want the bullet to stay on the layer once it has left the screen so I did the command ‘bullet player is on screen’ and then inverted it and told the system to destroy it. This basically means that whenever the bullet is not on the screen the bullet will be destroyed.

8: Player Firing Events
I added two number variables to the player. The first one being ‘CoolDown’ and the second one being Fire rate. I left the cool down initial value to 0 but changed the fire rate to 0.15. In the events sheet I added two new events. The first one is comparing the cool down variable to equal or greater than 0 and adding a condition telling construct to add delta time to the cool down variable this means that the variable will be shot out each delta time (every one second.). The next event was comparing cool down to its self and the fire rate and then adding a condition to set the value to the instance valuable, the value I choose was -1.  The next thing I did was changing the angle of which the bullets came out because I didn’t want the bullets to come out the same size/angle so I made a condition of setting the bullet angle to itself and at an angle of motion between the angle of -1 and 1 degree.






9: Weapon Power Up
To do my weapon power up which was to increase the bullet speeds once the player has collected a power up. I added a new variable to the player sprite and named it ‘weapon power’. I then went into the events and duplicated most of the conditions and the events and positioned it in a way which created more of the bullets coming out.  I then changed the value of each of the bullet angle in the different sections to make the amount of bullets increase. So later on in the game I can make an object which can change the bullets instance variable and give it a ‘power up’ effect which will give my player more bullets, Increasing the fire rate and making it easier to kill the enemy’s.
I also decided to change my background color to blue because I think it gives a brighter but also a more in  depth effect for the background. 







10: Hit point bar & HUD
I started the Health bar by adding a new instance variable in player called ‘HP’ This will basically mean that any bullet which hits the player the HP Bar will go smaller and another instance variable called Max HP. Making it easier to know how much life the player has. I put the HP Bar on the HUD layer so it is following the player throughout all the game but still staying at the bottom of the screen.  I created a black box to go behind the health bar to give the health bar a black background. In the even sheet I created a new group called player HP and then proceeded to add evens and conditions.
In the event sheet I added commands such as setting the HP width to the players HP to every tick in the system. This means that the HP width will go smaller and bigger depending on the players HP and this will happen in every frame in the system. I doubled checked to make sure the origin point in the HP Bar was to the left to make sure the HP bar reduces itself from the left and not centre.  I added an effect called set colour to the HP bar and then edited the properties and added events to make the HP point change colour when the health bar is decreasing for example green when the health is full, yellow when damaged and red when critical.




11: EnemyBug 1 & Spawn
I added a sprite using import frames from sprite strip and I imported my first enemy space ship. I looped the animation and then added another bug for its spawner. So when the player reaches the spawner the spawn will destroy it self and create the actual bug enemy which will then attack the player by flying him and shooting at the player. To add more enemy to the game I added more of the spawn sprites instead of just adding the moving enemy bug because this would of been too much for construct and more likely to cause an lag. I also put an event in for when I press the 'esc' Key the layer would reset and the player will start at the beginning of the game again. 



12: Enemy 1 Hit points. 


Firstly I began by adding instance variables 'HasSpawned' and 'HitPoints' The has spawned is an boolean which is set to false and Hipoints had the Number off 4.  In the even sheet I put events in basically telling construct for every bug enemy 1 spawned the bug spawn has to be destroyed and the bug enemey had to be spawn with the speed off 400 and the acceleration speed off 500 then only then the 'Hasspawned' Boolen could be set to true. After that the Bug enemy bullet speed went to 20 while the angle of motion was to the player and when the player was in sight the bullet acceleration would Increase to 500 creating the effect that the bug enemy is chasing towards the player.
If the bug enemy was in collision with the players bullet then it will destroy the players bullet and subtract 2 from the enemy HP. I added an effect called 'Brightness' to the enemy so every time the enemy is hit it will do an flash effect. If the Enemy's Hit points Is lower or equal to 0 or the enemy is no longer on the screen then the enemy will be destroyed. 




13: Enemy Firing
In this stage I wanted to add firing to my enemy sprite, I did this by adding three number instance variables called cool down with the initial value number 0.2, Fire rate with 0 initial value and Ammo with initial value of 1. I also created an false Boolean instance variable called shoot.
In the event sheet I did events to basically tell the enemy that when the player is in line of sight that shoot is set to true. Then for each enemy spawned the cool down valuable is equal to -1 and the ammo is equal to 0. When this happens the enemy bullet will be spawned and set to an angle of motion from the bug enemy, when the bullet is produce the cool down will be set to 0 and it will subtract 1 from the ammo. The cool down will be done every delta time, this basically means that the enemy will produce a bullet every 1 second and when that bullet has been produced it will reset the cool down and subtract 1 from the ammo. This will process will happen over and over until the enemy has either been destroyed or has ran out of ammo. 



14: Enemy Destroyed FX

Firstly I added two particle sprites with the enemy blood, One of them being green and the next one being more gray and black which gives an effect off blood and machinery exploding. In the event sheets I wanted to create blood 1 and blood 2 coming from out of the enemy when the enemy has been destroyed, Once destroyed the audio will play the sound effect for the enemy's death. 



15: Player Gun Audio & Enemy Fire Rate

I added an new instance variable for the Bug1Enemy called damage with the initial value of 50. I also added the same instance variable to the enemy bullet but with the initial value of 10. In the player Hit points group I added an new event basically saying that if the player is in collusion with the enemy bullet then the enemy bullet will subtract 10 HP from the players health bar and destroying the enemy's bullet. I also gave the player the same brightening effect as the enemy does when hit. When the players HP has been damaged to the point that the HP is greater than or equal to 0 then the player will be destroyed.



16: Adjusting Collision Masks
 I went through All my sprites for instance player, enemy, bullets etc to make sure collision masks are all in a appropriate position.




17: Player Destroyed FX

 Firstly I decided to change the appearance Of my players sprite so I made an new pixel sprite using Photoshop while at home. Once I was happy with the appearance of my player I went ahead and created an new sprite called 'players death' I gave the players death two behaviors called bullet and destroy outside of layout and then proceeded by going into the event sheet to edit these two behaviors.
 Firstly In the event sheet I started by putting in the condition that when the player is destroyed that the system has to create the players Death on Layer 3. Once done the width has to be set to delta time*16 and height to delta time *16 as well as the rotation being set to delta time * 200 which will create an shrinking spiral death, almost as if the player is crashing. Once I finished that I destroyed the player which will create blood 2 and play the audio sound 'shooting' which I thought was more appropriate for the players death. As well as the blood being created I wanted to add the engine part which gives an visual effect of the player being on fire when crashing and falling down. 




18: Maggot Launcher Part 1

I imported an spawnMaggotLauncher sprite as well as  my maggot launcher I which i gave  the behavior sine and destroy outside of layout. The sine behavior had to be adjusted a bit to give the maggot launcher a 'bulging' Effect almost like it is spitting out the maggots. To give the maggot launcher that effect I went into the event sheet and began by creating an new group called Maggot launcher. I then created an event basically demanding construct that when the scroll is 352 pixels away from the maggotspawners Y position then it must create the maggot launcher and destroy the spawn. I then put in another event so the system will do the bulge effect to the maggot launcher every tick (every frame) of the game.


19: Maggot Launcher Part 2

For this part I began by adding 4 instance variables called shoot with a false Boolean, cool down with 0 initial value, fire rate with the inital value of 0.3 and ammo with the initial value of 50. After I imported a new sprite and used the frame strip to import an animation of the maggots which the maggot launcher is going to create. I gave them the bullet behavior and set the speed to 200 with 0 acceleration because I want the maggots to instantly chase the player in a huge group.
 In the event sheet I began by setting the Boolean instance variable to true for each of the maggot launchers Once true the ammo will be greater than 0, making the cool down to equal one. When the cool down has reached one the system will create an maggot coming from the image point on the maggot launcher, Making it appear like it is coming from inside the maggot launcher. Once the maggot has been created it will set the cold down back to 0, subtract 1 from the ammo. This will carry on till the ammo has ran out for instance when 50 maggots has been produced each launcher. The cold down is set to delta time which means that the maggot will be spawned every 1 second and is set an angle towards the player although If the maggot leaves the screen it will be destroyed.






20: Maggot Launcher Part 3
For the final part to the maggot launcher I added 2 more instance variable to the maggot launcher. The first instance variable is called HP with the initial value number of 20 and another instance variables called 'hasSpawned' with an false Boolean.  I then added an HP instance variable to the maggot with the initial value 1 and an instance variable called damage with an initial value off 2.
In the event sheet I basically started off with when the player bullet is on collision with the maggot that then the maggot will subtract 1 from their HP and when the HP is equal or less than 0 then the maggot will be destroyed so overall it will take one hit for a maggot to be destroyed. Once the maggot has been destroyed the blood object will be created although the size will be set to the size of 48.  I added an event which means that if the maggot is on screen longer than the timer then the maggot will be destroyed and if the scroller is 400 pixels ahead than the maggot launcher then the maggot launcher will be destroyed. This makes it easier because if the player cant destroy the 50 maggots then they wont be on the screen all the way through out the game.



21: Bug 2 Enemy Part 1

In this section I added my second enemy bug which looks like a spaceship/Robot in a sort of a boomerang look. I create the spawn sprite and the enemy sprite like I did for my previous enemy. I then added two instance variables to the enemy called scale in as a false Boolean and another instance variables called scale with a initial value of 0. 
In the event sheet I put events and conditions so when the scroll is near the bug spawner it will spawn enemy 2 although that will the set the 'ScaleIn' instance variables to true so when the scroll is near bug enemy 2, bug enemy 2 will scale into the game.


























22: Bug enemy part 2
I added a new instance variables to bug enemy 2 called movement mode and set several conditions in the event sheet so when the bug enemy scrolls in the enemy will move around, To give this effect I added an sine behavior and modified it in the event sheet for instance setting the sine active when bug enemy 2 scale in is true.





23: Bug enemy 2 Part 3
In this section it involves a huge amount around adding an firing behavior to the bug enemy 2 and it damaging the player. For instance I began by creating the enemy bullet where enemy 2 is and when the turret shoot is on. When he enemy has ran out of it ammo which is 8 bullets the enemy will fly away. Although If the enemy is hit it will decrease 2 from its HP and once the HP is below or equal to 0 then the bug enemy is destroyed creating the blood particles. The enemy bullet is being shot towards the play and if it hits the player. Then the player will get 2 took away from its hit points with the brightness effect. 




24: Boss bug Part 1
For the first part of creating the boss bug I created an sprite and inserted the png image of the boss bug sprite which I re created in my own time. As you can see in the image to the right I have created the turrets separate well as the 'diamond' on the robot which is going to act as an missile launcher. In each of these sprites I have added the Pin behavior. So when The boss moves the sprites which have the pin behavior stay where I pinned them.



25: Boss bug part 2 
Firstly I adjusted the collision masks on my sprites to make sure the quality is better. The missile launcher on my boss has 5 animation frames and two different animations called open and closed. Om the event sheet I made sure that the sprites is pined to the boss enemy to o the exact position and angle and put the animate on open although stopped it and disabled the bullet behavior.  I also wanted my boss to scroll up the screen when the scroll is 538Y pixels away so then it gives an more of an boss effect for instance the boss is challenging the player. Also Once the boss has slowly moved towards the player it will stop and start the animation. 


26: Boss bug part 3
I added an instance veriable to the boss bug called can shoot, cool down and missile ammo. When the cool down=1  the boss bug cool down is sent to 0 and it should subtract 1 from missile ammo which will then shoot an missile. Then for each pod the missile will get shot out of the pod at an angle off 360/20 degrees 20 times. Once the cool down is greater than 0 the cooldown is set to delta time. When cool down is then greater than self.FireRate and the cool down is back down to -1 which starts the cycle of 20 missiles again.
When the missile ammo is less than 0 the can shoot is set to false and the missile ammo is set to 3. The system then has to wait 3.0 






27: Boss Bug Part 4
I've continued carrying on the bus bug by setting the boss bug mode equal to 3 which I then put the conditions for the system to wait 2 seconds then proceeding to setting the boss turret to enabled and to target the players sprite. After that the timer 'reload' will begin and after 5 seconds the mode will be set to 4.
The boss turret was adjusted so that the enemy bullet is at the boss turrets angle of motion is the same as the boss turret's. When the timer 'reload' Has started the turret is disabled and the sine is set to inctive as well as the mode being set back to 0.



28: Boss Bug Part 5
In this section I added quite a lot to the boss bugs events and conditions although this mainly involves adding the HP conditions to the boss bug, boss turrets, Boss pods etc. For instance In the image bellow there is a screen shot of the event sheets from my 2D Game. As you can see I started by putting in an event where if the boss pod is in collision with the player bullet then the boss bod will subtract 1 from its HP and have the same brightness effect as the previous bug enemy's. Once the boss pod has been hit then the players bullet will be destroyed. I set the boss turret HP like the the boss pod with the same brightening effects etc. Once I was happy with the effects I then proceeded by adding the events for when the HP is lower/equal to 0 for both the boss pod, boss turret and the boss bug.
For the boss pod and the boss turret which events and conditions are basically the same. I began by putting if the HP is lower/equal to 0 the the boss pod/boss turret will be destroyed which will take 2 HP points away from the boss bug it self. Once destroyed then the object blood 2 is to be created on layer 3 on the boss pod and then the audio 'enemy death' will start.

The boss bug is a bit more complex than the boss pod etc for instance when the boss bug HP is below 0 then the audio 'death3' begins playing which then the system will wait 1 second before destroying the boss bug and the boss turret. To give the player a more 'fancy' exit i added an timer called 'End of level' which basically makes the 'scroll' sprite wait 4 seconds before carrying on. This gives an effect off the player waiting while the boss is being destroyed and then having a 'victory' exit.
I wanted the boss death to be a big explosion so what I did was make sure the blood object 1 and 2 is being created with a size randomize off 120 although Instead off having one blood particle like the previous bug enemy's I put an event telling construct to make this happen 20 times. This basically means it will create the blood particles 20 times to create one big  explosion. 




29: Boss Bug sound FX, Player Damage & Layout change
In this section I focused more on adding the player damage for instance when the player is on collision with the boss missile then it will subtract the missile damage from the players HP which destroys the missile and proceeds with the brightening effects and The similar events and conditions happen when the boss bug is on collision with the player.

I added two new layouts to the game. One being the introduction screen and the other being the 'score' screen. So when the player has finished the 'end of the level' timer then the system will take the player to the score layout. 



30:  Power Ups & Scores
I created an new group to add the players scores and the power ups. The player score I set the the score initially to 0 although in every tick off the game the text I put on my game screen is to set to what the players score is. So this will automatically change the score in every frame off the game to make sure it is up to date with the players score points.

With the power ups I created an spawn sprite and the sprite for each power up like I did with the bug enemy's. although When the scroll is -352 pixels away from the spawner then the power up is to be created destroying the spawner. If the player interacts/collects the power up then the power up will be destroyed. There is two different power ups in my game, One being called 'gun spawner' which increases the weapon power by 2 and the other power up is an 'shield reset' which sets the player HP to the maxHP giving the player full HP.



31: Intro screen
I didn't want the game to begin to play straight away so I made a new layout and adjusted it so this layout opens up before the game loads. This layout is called construct and I basically inserted a sprite which i already made in Photoshop and used it as the background off my intro. I then created an new event sheet which will control what this layout does, Instead of using the game event sheet. In this event sheet I set an event 'when any key pressed' then load level 1. This means when the player presses any key on the intro screen then the game will load.




Here is a short clip off my 2D platform game