Your first game! Part 3: Collisions

Posted on: March 26, 2015 at 7:27 pm,


Part 1 | Part 2 | Part 3 | Part 4

Floating Rocks

In this part we’re going to look at putting the …asteroids into our asteroids game. We’re gonna make some floating rocks that you can blow up and that can blow you up.

Mostly we’re going to be looking at simple ways to use the collision event in GameMaker.

First off though we need a new sprite and object as usual, this time for our asteroids. I called mine spr_asteroid and obj_asteroid respectively.

We’re going to do something a bit different with our sprite this time around though. While our previous sprites had only one frame of animation, this time we’re going to add several frames to one sprite.

So create a new sprite and this time set the size to 64×64. After making the first frame, click this little button: in order to add new blank frames to the sprite.


now go ahead and draw three variations of whatever fancy rocks you want to fly around your game world. Try to keep them fairly square and straightforward, having them accurately fill as much of the 64×64 space as possible. This is important for collision purposes, as the more complex your shapes become the harder it is to create convincing collisions.


When you’re finished you should have something kind of like this, I kept mine simple just using the line and fill tools but you can do whatever you want:

normally having multiple frames like this would be used to create an animated sprite (and if you click the show preview button, you can see how this sprite would look as a strange flailing black blob animation.) but instead of animation we’re going to simply use these 3 different frames to semi-randomize the appearance of our asteroids. When they spawn into the world we’ll make them choose a frame at random from these 3 and stick to it without animating at all.

(And as always remember to center the origin of the sprite!)

Pages: 1 2 3