For my last game Multi I implemented a system which allowed for my game character to walk on and jump from walls based on collision handling from an article in the SoulHow Assistance Guides. I thought I’d share that Wall Walking System with you.
You have familiarity with writing code in Game Maker.
You have a basic understanding of writing simple physics code in Game Maker.
Your environments gravity pull objects downwards.
That you have handled cases where your character can move on horizontal surfaces
The following Wall Walking System allows a character to walk in a variety of different situations that I’ll illustrate and refer to using the following diagram.
On completing this short guide your should have a better idea on how to have your character walk in the following cases:
Green Case – Left, Right on Horizontal Surfaces
Blue Case – Up and Down Completely Vertical Left Walls
Red Case – Up and Down Completely Vertical Right Walls
Purple Case – Left and Right on Vertical Ceiling Walls
In addition your character will also be able to jump up, down, right and left in the Green, Purple, Blue, and RedCases respectively.
A caveat of this Wall Walking System is that it will not work in the corner cases highlighted by the orange lines due to not specifically handling the effect of the assumed environments gravity. Now on to the system!
When searching for a teleport system in Game Maker, I often find the following suggestion. When object A collides with object B at position (x,y) change object A’s position to (x_new,y_new). This works perfectly if you require a fixed position teleport system.
Though, what if you wanted (given any character position) to be able to teleport to a location that is not pre-defined. A dynamic teleport. What do you do? I asked myself this, and here’s a simple solution that I used for my puzzle platformer Multi.
First lets define a few terms and variables:
Ideal Teleport – A teleport which results in the character being where you most want in a regular scenario.
Teleport – A boolean variable that determines whether the character can teleport or not. It is reset with the use of an alarm.
Teledist – A fixed integer that determines the position change of the ideal teleport. I used the value 96 pixels.
Par_solid – The fundamental solid object of my game (I did not use Game Makers solid variable, this article explain why.
It also helps to know the basics of Game Maker Language’s (GML), and how one of its functions place_meeting works. If not I suggest you check out this great post in the Game Maker forums by Torigara.
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:
Getting it plugged in.
Figuring out how it works.
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.
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.