A Trial of Platforms Part 2 – Building a Simple Platformer Engine in Game Maker

platforming

Writing a good, feature rich platformer engine takes a lot of work. Building a simple platformer engine is considered a case of ‘reinventing the wheel’. So it makes sense why some choose to find a pre-built engine to plug in to their game.

The trouble with this can be:

  1. Getting it plugged in.
  2. Figuring out how it works.
  3. Finding it doesn’t do exactly what you what.

Seeing as the feature needs for a game I’m building are simple. I instead decided to learn the basics then build such an engine in Game Maker. For now, I’ll briefly run through the resources that helped me build a major part of what I’ve implemented. Collision detection.

Implementing collision detection can be a head ache if your new to ‘game physics’. So to help you on your way here is a good video by Shaun Spaulding which gives an in-depth look into how to create a platformer in Game Maker. I’d recommend watching the whole thing, in particular where he explains the basic concept of collisions at about 22:30.

collisions

The system he describes is basically a method of checking several pixels ahead per frame. If a situation arises where two objects intersect, move the moving object to a point where they are next to each other but not intersecting. This is the method I choose; there are many many ways of doing it.

Another popular method for dealing with collision detection in Game Maker is to use the ‘solid property’. By marking objects as solid, Game Maker will handle the collision detection between solid objects. It’s a good place to start, but it can be problematic and clunky, particularly if your using moving objects. If you want more detail SoulRed12‘s article on why not to use solid explains why.

say-no-to-solids

ASIDE

For those of you who are more familiar with Game Maker, I’d like to point out an issue I had. Be careful when using y_scale and x_scale to turn your sprite left and right. Doing so changes the masking box and can cause the sprite to become stuck on corners. This happened to me despite both my collision code working and the masking box between sprites being the same. The result; a little part of my sanity lost to the void whilst checking over and over again, for an issue that wasn’t there.

END OF ASIDE

Personally, I agree that not using Game Makers solid is better as it gives you more control and understanding over what is happening in your game. So here’s another little gem from SoulRed12 giving you a complete platformer engine with pixel perfect collisions without the use of solid. To see a working implementation of it, checkout my game Multi!

This well written and documented code I used as a foundation for my engine. On top of it I added simple features such as checkpoints, wall jumps and character teleports. If you’d like me to explain how I implemented any of these features, feel free to leave a comment below. I highly recommend that if you have Game Maker, try building your own platformer engine. You might pull out a hair or two at first, but the experience is worth it.

1 thought on “A Trial of Platforms Part 2 – Building a Simple Platformer Engine in Game Maker

  1. Appreciating the time and effort you put into your blog and detailed information you provide.

    It’s awesome to come across a blog every once in a while that isn’t the same out of date
    rehashed information. Excellent read! I’ve bookmarked your
    site and I’m adding your RSS feeds to my Google account.

    For a better informative review please take a look at this website ::
    click here

Leave a Reply

Your email address will not be published. Required fields are marked *

2 − one =

This site uses Akismet to reduce spam. Learn how your comment data is processed.