The Platform Problem
Home Up The Platform Problem Events continued


The platform problem

All too often platform engines seem to have strange code in several events, often without a clear explanation of why its there. Sometimes an engine can be used as is, but sometimes the programmer may want to add new behaviour and they need to understand the platform engine to be sure the new code does not cause conflicts with the existing code.

I'm going to assume that we want a platform game engine with accelerating movement.

Ideally the engine should use hspeed and vspeed for the speed values so the programmer can use regular GM functions for movement.

Objects should stop accurately on platforms. I'm going to assume that platforms will be solid at this stage.

We want to avoid objects becoming stuck in platforms.

We want to avoid objects falling through platforms

We want to avoid objects sticking to walls or being able to do unwanted wall-jumps.

The problem with using Collision events for a platform engine is that the uncertainty in the order of collisions can cause things to come unglued.

Example of problem:

Lets say we have a "sumo" monster that pushes the player away, and the player is backed against a wall. There is a collision with wall event that puts the player just outside the wall. Now if the monster collision is evaluated first then the wall collision afterwards the player ends up against the wall, but if the wall collision is evaluated first the player ends up in the wall, and may become stuck.

It's possible that the above scenario could occur only on some levels of a game, and might appear and disappear during editing.

There is a further inconsistency in that when an object collides with a solid object its position is put back to where it was prior to the move. This appears to mean that if an object is in a clear position and a move causes several collisions only one will be evaluated as after the first collision the object will be moved back into the clear.

Things are more reliable if only the speed of an object can get modified, but even then there are potential problems. If an object is set to bounce off walls, and something else changes its speed so that at the point when it bounces it's direction is already away from the wall then the bounce will leave it travelling towards the wall and it will quite possibly become stuck. This has happened.



Home Up The Platform Problem Events continued