Task 4 Using A 2D Game Engine

Note: The sprites may change as the screenshots are taken as they are not fully complete.
1. INTRODUCTION
Firstly I set the height and width of my window size to 480, 640 to give it an elongated look as I am doing a vertical scroller.

Then I changed the layout size of my level 1 to 480, 3200 so that the level has a thin and long base.


Finally I had to make sure each layer was transparent except for my bottom background because if that was transparent it could cause some problems.


2. TILE SET

 My next step was to place the bottom tile set into the game. I placed it on the layer BG1. To help keep it clean and tidy I would tick and untick the snap the grid button at the top of the screen and show grid.

I then had to drag the image down which gave it the tiling. As you can see the back ground looks like a full road instead of just a block.


I then locked BG1 and clicked the BG2 layer as I needed to include my next back drop, I imported my transparent cloud tiles into the game and did the same as the back ground where I dragged it down to create a tiled version.

3. TILE MAP
To next step was to make a tile map over the game, I had to import the image of the tiled platforms and place them around the level to create different shaped platforms that would fit into the background.

For some of the edges of the tile map I had to change the point of contact so that the player would not bump into any invisible walls.

This is what my level looks like with all my platforms placed inside.

4. VERTICAL SCROLL & PARALLAX
Now I need the game to scroll, to do this I needed to create a sprite and resize it to 32 by 32, I then had to change its point of origin to 0 by 0 so that it would fit into the grid.
To get the game to scroll I had to change the angle of the sprite by 270 degrees and set the position of 224, 2880 so that it would be in the centre of the game.

 Next I had to add two behaviours, a scroll to so that the camera would be connected to the sprite and follow it and a bullet behaviour so that the sprite would move. Then I disabled the "set angle" and slowed the speed down.
 Fianlly, I added a parallax onto BG1 and BG2 to make the objects that are further away seem like they are further away.

5. PLAYER SPRITE AND MOVEMENT

Next I had to import my player sprite into the game. I also had to add an animation onto how he moves through the game. My animation of him is a jet pack on the characters back which will flash to show his movement. To do this I had to create three animations on the bar on the right, then for each key animation I had to import the different sprite animations into the bottom bar. Then to the left I had to loop each animation and set a certain speed at which the animation will go.

Then I had to add some behaviors onto my character, these two behaviors are the 8 direction and custom movement, the 8 direction behavior allows the player to mover the character into all directions which then could be edited to the left. I changed it to become a 4 angle movement so that the player continues to look forward and set the angle to off, I also had to change the movement speed, acceleration and deceleration for better movement. The custom movement behavior came in handy for when I needed to program.

Finally, came the programming, I had to program the game so that my player would stick within the screen of the scroll sprite. This is so the player does not get left behind in the game. I also had to make it so the player would not go off the screen. I did this by using the window size to determine how it would stop the player from going off the screen.

6. PLAYER ANIMATION & PARTICLE FX

To get my player to animate left and right I had to code into the event sheet the actions and create the animation to play when holding down a certain key.

 Next I had to include a particle function for my jet pack stream. Then I had to change the properties around so that the stream would disappear after a while. I also had to change how fast the particle animation came out and the spray cone which stops it from spreading. I had to change the grow rate so that it became smaller as it got further away and change the size randomiser so that it would come out looking different sizes with each particle. I also had to change the timeout so that it faded away faster and the acceleration so that it came out at a good speed.

I then had to create two image points on the characters animations so that I could script the particle to come out of the boosters.

My final step was actually programming the particles to come out of the location of the image point.

This is what my game looks like with the particle effect boosting the player as they press forward with the keys.


7. PLAYER FIRING EVENTS PART 1

Next I had to include my player bullet sprite and give it the bullet behaviour so that it would fly upwards.

I also had to prgram it to fire from the player and change the point of origin of the character so it came out of his gun, Finally I also had to script the game so it would destroy as soon as it went off screen

8. PLAYER FIRING EVENTS PART 2

To get the gun to fire with a delay I had to add two variable, a fire rate and a cool down rate. Cool down is like a timer that resets once it reaches the number that the fire rate is.

Next I changed the space bar script so that when it is held down it will fire continuously instead of having to repeatedly press space. However, this will make the bullets come out one after another in rapid succession. The scripting of the cool down and fire rate will make sure they come out in a timed fashion.

The bullets cool down is equal to -1 and set to 0. Then I make sure that it counts up in dt (delta time) which enables the numbers to increase by 1. This will make the cool down go from -1 - 0.


Next I had to make sure the bullet looped from 0 back to -1. To do this I had to script my fire rate so that it would reset the bullet time once it reached 0. This would produce a bullet every second then until I changed the variable number to the left hand side on the player sprite to being 0.15 which gave it a faster fire rate but not to fast. I also had to script it so the bullets came out of the gun, I used image points to help me and I made the bullets have a angle of motion which gives it a sway type when being fired.


Finally, I added a flash to the end of the gun to make it look more realistic when the gun is fired. As seen below is the full scripting for the mflash which is a sprite that appears every time the gun is fired.

9. WEAPON POWER UP

Next I wanted my gun to have an upgrade as the game progressed, to do this I had to create another variable on the character known as weaponPower, I added an extra condition underneath the cool down and named scripted it to be weaponPower 0 as the gun had no upgrades yet. I then coipied the whole scripting and placed it underneath, I changed the variable from a 0 to a 1 so that when the player picke dup a power up it would change to this scripting. I also had to copy and paste the bullet so more were produced and change the angle so the spread of the gun was further.

Since I want multiple power ups throughout the level I had to copy the scripting multiple times and increase the amount of bullets that would be fired and the angle to give more of a spread. I also had to edit the fire rate so that the more power ups collected the faster it would go.

Below is two screenshots that show the effects of the power ups. The first shows the game without any power ups and the second shows the game after you have collected three power ups.

BEFORE

AFTER


10. HIT POINTS BAR & HUD




Now I needed to create my HUD, I did this by creating two sprite. One sprite would act as the health bar and the other would act as a backdrop that the health bar would sit on so the game looks professional and less messy.
Next, I needed to make sure that the health bar would decrease when the character got hit by an enemy or enemy bullets, to do this I had to code the bar so that it would decrease in size. I also had to change its origin point as the health bar would decrease towards the middle instead of going from right to left.

Next I added a colour effect on the health bar, this enabled the health bar to change colour the lower it got going from a light blue toward a dark purple to show the player that they are low on health. The colour will also start to fade from blue to purple as the health bar decreases creating a blending effect.

These are the list of variables that will be connected to the player sprite along with the current health value.

The next two screenshots show you what the health bar looks like both full and when the player is on low health when the game is playing.

FULL HEALTH

LOW HEALTH

11. ENEMY 1 SPAWN & MOVEMENT
For the next part of the game I had to include my first enemy, to do this I created two sprites, one would be the enemy while the other would be the spawn point.

To get the spawn point to spawn an enemy I had to start scripting, as seen below I scripted the game so that they would spawn when the player came into a certain distance of the spawn point.

An effect of the first scripting process only allowed one spawn point to spawn an enemy, to change this I had to include another condition along with the first that would allow the enemy to spawn at multiple points. I also needed the spawn point to get destroyed so that it would not appear in my game so I scripted the game to destroy the spawn point.

The enemy needed to have two behaviors, one which would let it move and the second behavior would destroy the original sprite. This stops any sprites from spawning into the game without a spawn point involved.

The next area of scripting involved the speed and angle at which the enemy would come towards the player, firstly I got the speed scripting done and made sure that the enemy would come down from the spawn at a high speed but would also decelerate as it got onto the screen giving it some time to position the angle.

Below shows the scripting for the angle of the enemy, this allows it to face the player after it has slowed down at which it will accelerate towards them committing a kamikaze attack.

The next screenshot does not show any scripting for the enemy but shows a simple way of how to restart the game without having to keep closing the window down, instead you can click a button.

Finally, I wanted the enemies that had spawned to destroy once they had gone off screen since they will still generate as the game plays. To do this I had to insert a Boolean variable (also known as a true or false variable.) This will allow the scripting to destroy the enemy after they have gone off screen.

The screenshot below shows off the scripting that was made to destroy the enemy once it had gone off screen, as you can see it the Boolean variable with the true action.

Below shows my game with the correctly programmed enemies attacking the player.

12. ENEMY 1 HIT POINTS

The next step was to give the enemy health so that it could get destroyed, firstly I had to include an instance variable. This variable would allow the health to have a number.

Next I had to script the bullet and enemy so that the bullet would cause harm to the enemy, the bullet will subtract the health by one.

Once the variable number of the health reaches zero or lower it will destroy the enemy.

Then I included an effect on the enemy, this will give an indication to the player that the enemy has been hit as the enemy will flash.

The scripting for this effect is shown in the screenshot below, it shows how the parameter will happen within 0.05 seconds of being shot.

The screenshot below shows two enemies, one that has hit (on the right) and the one on the left (who has not been hit.)

13. ENEMY FIRING
Next, I needed to give the enemy some bullets to fire at the player. This would mean that I would have to put some variables onto the enemy.

I also had to give the enemy bullet sprite a bullet behaviour so that it will move in a bullet motion.

The enemy also had to have a behaviour added, this was a line of sight behaviour which allows me to script the enemy to face the player once it stops so that once it has turned to face him it will shoot.

The scripting below shows what I did to make the enemy shoot towards the player once he was insight, I had to make sure each enemy did this action.

Below shows the scripting of the ammo and the bullet being created. I had to script the game so that the enemy would fire and create a bullet once its sight was attached to the player, I also had to make sure that it only fired a singular bullet.

Below shows the cool down system, this prevents the enemy from firing another bullet against the player.

I also had to make sure the bullet that the enemy fires would get destroyed once it went off screen.

Below shows a screenshot of the enemy firing at the player.

14. ENEMY DESTROYED FX


I had to give my enemies a death effect, to do this I had to include two new particle sprites. I the had to script the particle sprites to appear once the enemy had been destroyed. To the right of the screenshot below shows all the tools to change how the particles will happen. It controls the particles speed it will happen, time on screen, whether it is one-shot or continuous and etc. The screenshot below shows the first blood particle edited.

This screenshot shows the second editing I have done for the second blood particle.

I also wanted to include a sound so that it sounded like the enemy had exploded once it had died. I made this sound using software known as reaper. I then imported the sound and scripted it into the enemies death.

Below shows the editing of the sound when scripting it, as you can see it can either be looped or not looped and the sound can be edited to be louder or quieter.

Below shows the particle effect happening in game.

15. PLAYER GUN AUDIO & ENEMY FIRE DAMAGE

Next I wanted to include sound when the main players gun fired, I imported a sound I made on reaper and scripted it so that when the space bar is pressed down the sound will continue to loop as it shoots. I also scripted is so once the space bar is released the sound will stop.

I then included an instance variable on the robot enemy called damage which has a value of 10...

...And did the same to the enemy bullet.

I then had to script it so that when the enemy bullet hit the player damage would be done and 10 points of health would subtract from the players health, I also had to make sure that the bullet got destroyed as it hit the player.

I then added a brightness FX to the player so that once he was hit he would flash just like the enemy does when the players bullet hit them.

I repeated the process so that when the enemy dived towards the player it would get destroyed and take health away form the player, it will also cause the player to flash. However, I had to change the scripting from destroy to its health variable so that the enemy would have the action of being destroyed with blood shooting out.

Once the health reaches 0 or lower then the player will be destroyed.

16. ADJUSTING COLLISION MARKS

For mt game to work properly I needed to change the collision points, this is because if I did not change them then they would be in the incorrect location and cause the player to die much easier. As shown in the screenshot below if the bullet hit the part of the collision marks that is circled then the player would get damaged, this would give them an unfair play through of the game as the bullet does not even have to hit the player.

This is what my collision marks look like for my player.

 This is what my enemy collision marks look like.

This is the collision marks for my player bullet.

This is my enemy bullets collision marks

17. PLAYER DEATH FX

For my next step I wanted to add in a animation effect for the player once they had died. I added in a new sprite and added two behaviors (a bullet and destroy of screen) to it so that the original sprite off screen would destroy and so that it would still scroll instead of staying in place.

I needed to script the game so that once the player had got the destroyed the player death sprite would replace it.

I then gave it the animation/effect of rotating and getting smaller so it looks like it plummets towards the ground.

Once it reached a height of 0 or less then the player death sprite will destroy.

As it rotates towards the ground the engine boost that the player has will begin to spiral with it to give it that extra effect of it being shot down.

I also wanted some blood to spawn as the player blew up so that it looked as real as it could.

18. MAGGOT LAUNCHER PART 1

Video: