2d game printscreens

45
Firstly, I started by making a player sprite. After finishing my design, I gave it an ellipses mask as the shape was roughly similar to my sprite. Next, I programmed the movement code for my Player sprite, so that

Transcript of 2d game printscreens

Firstly, I started by making a player sprite. After finishing my design, I gave it an ellipses mask as the shape was roughly similar to my sprite.

Next, I programmed the movement code for my Player sprite, so that using the w,a,s,d keys, I was able to control the direction my sprite moved.

Then, I started to make a background for my game, since my sprite was a space ship, it seemed appropriate to have a space background, therefore I made my first background a bunch of stars in space.

Next I created a foreground image that would overlay on top of the first background and scroll slightly slower in order to give my game the feeling of depth.

Then, I began creating a sprite for some smoke that would be used in a particle system for the jets of my player sprites exhaust.

This is the code for my particle system. It makes the sprite fly out of the back of the player ship towards the left side of the screen in a random way, similar to what an actual exhaust would be like.

In order to get my player able to shoot enemies, I needed to create a laser that would be fired from my ship. First I created a sprite that would be used as my laser.

Then I programmed the code so that when fired, it would move towards the right of the screen from where it was fired. It would also play a custom sound effect that I made myself using reaper.

Then I added the step event that checked whether the the laser was off the screen and if so, destroy itself. This is so hundreds of lasers don’t build up outside the screen and crash the game.

Them, I went back to the player code and added an if statement that when the space bar was pressed it would fire a single laser.

Here is what my game looked like so far:

Now that I had the ability to shoot, I needed something to shoot. I created an new sprite that would be the first enemy of the game.

I added a slight animation to the sprite that moved a few lasers along the back of the ship.

I needed to add my enemy to the game but at random intervals and positions. Therefore I added this code that spawned the enemies in a V formation randomly from the right of the screen. Then I added an alarm that reset the spawn of the enemy from between 1 ½ and 2 seconds.

Then I added the create event that began the alarm.

In order for everything in my system to appear in the main game, the object had to be placed into the physical level. However, since it had no sprite it would be invisible to the player.

Then, for them to move towards the left side of the screen, I changed their H speed to -10 and their image speed to 0.7 so that it would cycle its animation at 0.7 of its normal speed.

Similar to the laser, if the enemy left the room it would disappear so as to not crash the game with too many instances.

Here is the formation of which the enemies spawn.

Next, I created an explosion animation for my enemies so that when they died they didn’t just disappear.

I used the same particle system code except I changed the variables and sprite used.

Then in the enemy object, I created a collision event that when hit by the player laser, it would play the explosion object.

Here is the enemies exploding into the explosion object.

I needed my enemies to fire back at me, therefore similar to the player, I created an enemy laser.

These laser would move towards the player at whichever point the player was when the laser instance was created.

This laser had the same code as the player laser where it would be destroyed when it left the room or when they hit the player.

So that the player wouldn’t instantly die when a single bullet hit them, I implemented the code for shield/ health bar that when a bullet hit the player, the shield would go down.

This code drew a red line in the actual game that showed how much life the player has and decreases when the player is hit.

Then in the player object, I set up a collision object with the enemy laser that when hit, it would decrease the shield by 10 points.

I then began work on a player explosion for when the player died.

Once again, I used the same particle system apart from changing the variable and object again.

Since this was the player explosion, when it ended after the alarm finished, it would destroy the explosion instance and it would restart the room so you could play again.

Then I had to go back to the player object and add the code that every step, it would check to see if the player shield was at 0 and if so, it would change the instance to the player explosion.

I wanted to add a scoring system, therefore I began by making code similar to the shield by m,aking a points variable and setting it to 0.

Then I created the code that would draw the score at the top of the screen.

In order for it to draw numbers, it needed a font, therefore I made one.

Then, I went into the enemy object and added code that when hit by the laser, it would add 1 to the score count.

Since it looked bare with one enemy, I added a second enemy with a flashing animation.

Alongside my new enemy, I created another enemy laser which it would fire.

Then I made the second enemy's spawn alarm to 2 seconds.

Instead of having this enemy spawn in a V formation I decide it would make things to hectic, therefore I only made one spawn at a time.

Then I added the code for it to shoot at the player, as well as all the other code from the first enemy.

Here is the game with two enemies on screen firing.

I wanted to add a bit extra challenge to my game, therefore I decided I wanted to make a boss for my player to kill. I began by making the sprite.

I placed it just off screen so that when the level starts, it moves left onto screen for 55 steps where it stops.

Before I continued with the boss, I wanted to make a start screen so that players wouldnt be dropped immediately into the action. I started by making a start button with two images, an on and off image.

I made it so when the mouse hovered over the button, it would change to the on sprite and when the mouse left the button, it moved to the off sprite. Also, when the button it would move the the main room.

The start screen looked quite blank, therefore I created a little sprite that would float across the screen, to spruce it up.

I added plenty all around the start screen and created code that would make them float up to the left and out of the screen as if they are an armada moving through space.

One thing I found was that the screen was very dark when playing the game, so I decided to make a large planet that would fly across the screen in the background as the game was played. I went into photo shop, created a larger sphere with a blue gradient and used a cloud like brush to make the clouds and used a bunch of tiny white dots to act as lights on the planets surface on the dark side.

Using the same code as the boss, it moved from halfway on screen to completely of the left side and after it moved completely off it is destroyed so as not to possibly crash the game in any way.

Here is a size comparison of the planet to the actual level.

After I was happy with the background, I continued work on the boss, creating a destroyed/damaged version of the boss that would appear as parts of the boss are destroyed

I seperated the original boss sprite into three in order for them to be destroyed seperately.

I gave each the same movement code as the original boss so they would move in unison and not slip out of place.

Then, similar to the other enemies, when the player appears it begins its alarm to fire its laser.

So the pieces of the boss aren’t immediately destroyed I gave each piece a shield that had lots of health to be worn down over the course of the fight

for the two cannons on each side of the boss, I created a large bright laser that would do large amaounts of damage to the player and also home onto him.

For each step, they would check if their individual shields were below 0 and if so they would be destroyed, revealing the piece of broken ship beneath it.

Finally, I set up a collision event with the player laser that would take 4 health of their shields with each hit.

When the boss' middle section was destroyed, I want it to progress to a new stage of the boss battle, therefore, I created a new red laser that would rapidly fire from the middle and do plenty of damage.

This is the same homing code as enemy1 except the alarm is sped up quite a lot, thus making the laser fire in much quicker intervals.

This is how the ship pieces look when not on top of each other...

and when they are.

I decided I should make a unique explosion for my boss to make it feel unique when killing the boss.

I set up an alarm in the boss explosion that destroyed itself and also signalled the game to move onto the win screen.

For the win screen, I created a fancy box that had some end text inside congratulating the player for their accomplishment.

Also in the room I had a retry button that restarted the game again in order for the player to try to get the high score.

For the death screen, I cut up the player sprite into pieces as if they are floating in space after being defeated and turned them into their own object.

Also, I created large text that would move down onto the screen after a few seconds.

This code moves the text from off screen and stops it on screen.

As for the dead player sprite, I made it move left and down very slowly as if all that remains is the

pieces of the players ship floating through space forever.

This is a zoomed out view of the death screen.

The final thing to do was add music to each room to add spice to the game.

In each room, there is an object that has code for stopping all other music and starting that rooms specific music. For example in the main room, its the system that has the code for playing the background music and stopping all other music.With this done, my game is in its finished state.