Thursday, 21 January 2016

Game Maker: Creating Space Invaders.

Step 1: Sprites

The very first thing I did was create the Sprites, I decided to make a clone of the original Space Invaders. First I created the Tank from the game (shown below, left), Next I created the first Alien, I copied the original Alien shape (shown below, right). The Sprites are all going to be 32x32.



Next, I started making animation movement for the Sprites (as seen below), I started by making a new page within Edit Sprite section and slowly making the aliens arms go up and its mouth close sort of like stop motion. When they are played in the game it will all play together and should look like they are trying to eat as they move down.



Step 2: Converting to Objects.

After that, I converted all the sprites to Objects (as seen below), I also began making the aliens and the Tank move with the Drag and Drop system, I had to change the design of the walls because sometimes the Tank would get stuck in the flooring, I eventually had to make the Wall and Floor a separate object as it had something to do with the Aliens being programmed to bounce on the wall when a collision occurs.



Step 3: Creating Rooms.

In the next lesson I created my First Level, as you can see I have based it entirely off the original game with the Aliens, Barriers and Tank. I also started making the Aliens slowly fall lower and lower down the screen toward the Tank, like in the original game. Next, I learnt how to make the Aliens shoot bullets down and also make the Tank shoot back at the aliens.



Step 4: Shooting Bullets.


As I said in my previous step, I next learnt how to make the Aliens shoot down towards the player and also get my Tank to shoot back up at the Aliens, I have now learned how to do this through code (as shown below). This is the code for the Tank to shoot upwards at the Aliens, as you can see in the first line, when I press the Space-bar, it will create a bullet instance at the speed of 15 in the direction 90 (upwards). To create a bullet I simply just drew out a white line as a sprite and converted it to an object.



For the Alien shooting downwards it was slightly more complex as I wanted the Aliens to shoot down at the Tank in a random order, to do this I had to create an Create Event in D&D, within this I had to create an Alarm and set it to 0, then in the Alarm event create a Random Chance (dice icon) that every 6 steps it has 1 chance of shooting a bullet. I set this to every Alien so when you play the game the Aliens will all randomly shoot down.



Step 5: Creating Points System.

The next thing I did was create a Points System at the top of the level (as seen below) whilst doing this I decided I would create more levels as well and also create a title, to make the title I opened up Paint and wrote some text on the background, when I uploaded the background to Game-Maker it fit perfectly at the top of the page, next to this I wrote the level (as seen on the top left) in the image below you can also see how the Aliens will be falling downwards and also the bullets shooting.



To create the Points system as seen in the top left of the screen I had to first create a Controller object, I named it 'controller_score', next in this object I made it reset the score to 0 straight the way. Next I created a Draw Event, in this I put the co-ordinates where I wanted the Points System and what colour, font and text size I wanted it to be. Then it was all done and all I had to do was add the Controller object onto the level screen but made sure to set it as non-visible so when you play the game you couldn't see it.



Step 6: Title Screens.


In the next lesson I create some title screens for the beginning of my game and the beginning of each level, also one for the end of the game if you win and also if you die and get a Game Over screen. To do this I made a new room and called it 'room_titlescreen', next I went into Paint again and created a a title screen, with the Space Invaders logo, my name and also 'Press Any Key To Continue', all I then had to do to get it working was put a controller object in the title screen room with 'When Any Button is pressed - Move to Level1' D&D system.



Next I had to create a end screen for if you lose and if you win, again I went into Paint and created a basic background that said either 'Game Over!' or 'Congratulations You Won!'. Then I decided to get a little bit fancy and add buttons in to restart the game or quit the game when you're done. I went onto a website called Button Maker and designed and downloaded my custom button saying 'Quit Game' and 'Restart', Next on my Game Maker screen I made the buttons into sprites and put them into the correct places as objects. I went into the events of these buttons and made it so when you press the left click on them, it will either Restart or End the game. Pretty simple.



Step 7: More Levels.

In the next lesson I decided the game wasn't difficult enough and needed more levels with more of a challenge, to do this I very simply just created a new room and basically exactly copied my previous rooms, I did make some adjustments such as removing one barricade on the second level and also moving the Aliens down by one line so you have less time before they get to the Tank. To set it up so when you beat one level it goes to the next one I created some code where it basically says that if the points system reaches 50 (which is the amount of aliens I set). It would change the to the next level (the code is seen below)



I made this on each level so when you finish the first level it goes onto the start screen for Level 2 where I set another title screen informing you thats its Level 2 and press any key to begin like I showed before, quite simple.

Step 8: Difficulty and Finishing up.

My final step is showing how I made the game a little bit more difficult to beat, I basically just cranked up the speed of how the game played through level frame rates, by the 3rd level it is playing at 60fps and my game is only set to play at 30, so this made everything super faster. The final level is almost impossible to beat although I have beaten it once. I then thought about adding life to the barricades so they eventually will be destroyed. I decided against this as the final level was too difficult else. I did eventually add that if the aliens got low enough to be level with the barricades then they would be destroyed, as it is in the real game, your main priority is killing the lower aliens.



See The Terrible Finished Product Here:
https://www.youtube.com/watch?v=LsUA-rwnV1k&t=3s

Comparing Code to Killer Klowns Game:

The Coding in this game was very different to the coding in my Killer Klowns game, for one it was a lot more complex in Killer Klowns and was a lot more liable to get messed up.



This was some basic code for Space Invaders I created, it essentially tells the game to count how many points I have obtained for destroying Aliens and once I have obtained 50 points it will move me to the next room or next level which progresses the game.



This is some more code for my Space Invaders game, this is essentially telling the game to create a Bullet object to shoot upwards 90 degrees every time I push the Space-bar. This bullet is also coded to destroy Aliens when it hits them and also to self destruct when it hits anything other than an Alien.

No comments:

Post a Comment