How to Build an Asteroids Game
Hello! Jeff for the Click Team here and today we’re going to be making a simple Asteroids game. So let’s just start a new application and let me open up a graphics file for some graphics for a game. Put a background on here, put that at zero-zero. Lock it in, ship, and off-screen we’ll do our explosion, our shot, large and the medium. Okay, that should be enough for us to get going here. Okay, we’re going to highlight both of our rocks so I got them both selected and I’m going to add this to a qualifier group and this will just simplify my code a little bit because I can a test a group all at once.
Now, I still have them both selected and I’m going to set their movement to bouncing ball and let’s set the speed down to 15. Okay, on our explosion, I want to just give it a little effect and so under ink effect, I’m going to do an Add. This will kind of give it more of vapory type of explosion to make it look cool and let’s go into our ship. Our ship is going to get the spaceship movement. That went off the screen but its way down here at the bottom. Trust me it’s there if you look. Okay, let’s crank up our thrust power to about 50, a rotation speed about 30, gravity zero, gravity direction, and I’m going to unselect everything. Okay, that should be about it. Let’s run our game right now. Okay, we’re rotating pretty good. We’re thrusting.
Okay, so let’s go do some programming now. Everybody knows how asteroids work. I won’t have to explain the game for you. First thing I’m going to do is for the rocks to wrap around the screen and I will test this as a group and I will test the position of group that I add for all four of those going out of the frame and that’s just a simple movement wrapped around the play area. So if we ran our application now, you will see when a rock exits one side, it enters on the other side.
Okay, let’s do the same for our ship and I that one of course will also just stay wrapped around play area. So if you fly off one side, you fly into the other. Okay, so we probably need to do some shooting now and some collision detection and let’s do the shooting first and keyboard upon pressing the key. I want to pick the space key. Our ship here is going to launch an object, the plasma shot and it’s going to launch it in the direction of the ship. Give that guide a quick test. Okay, so that looks pretty good.
Now let’s test for the bullet hitting the large rock. Okay, so when this is through, I want o destroy our shot and I want o create an explosion and that’s going to be relative to the large rock and I also want to create a medium rock and that’s also just relative to the large rock and then I’m going to create another medium rock relative to the large rock. And then I’m going to destroy the large rock. Okay, I’m going to copy this event and I’m going to edit this to be the medium rock and I’m going to delete, create medium, I’m going to delete, create medium, and I’m going to destroy the medium. That looks about good. Let’s run this and see how our game looks. Well, something went wrong there.
Well, we need to edit this. We are creating our explosion relative to the large rock. We want it relative to the small rock. The products make it easy but not idiot proof and we can still have logic hairs. Okay now, we need a few more rock to generate, so let’s do every three seconds, we’re going to create an object and it’s going to be a large rock and we’ll create it off-screen down here.
So unless you get to work cleaning out the asteroids, it’s going to get busier and busier here. So I think you can see that the basics of how game development and design is made in Multimedia Fusion but we didn’t do any collision detection for our rock hitting the ship; very probably important. Collision with group bad and then we’re going to create an object which would be the explosion relative to the ship and then we will destroy our ship. Alright, now it’s a little bit more challenging since the rocks can actually destroy us. So in educational setting, the students are going to be having logic hairs but they won’t ever have any syntax hairs. So they won’t be frustrated by syntax that’ll be just using their brain to develop the video game in computer programming logic. Thanks a lot!
Transcription by:
Scribe4you Transcription Services