I've been working on a custom platformer engine with someone, and we cannot get past this one simple problem. Supposedly, loops run within a single step instead of per step. However, the actions I've placed within these loops are running per step.
This problem has been driving me crazy for days. I've tried all kinds of tricks, workarounds, variations, and every type of loop. I've simplified the code as much as possible trying to defeat this.
This should be a basic, straightforward collision system. All it's doing is:
while object overlapping solid
shift the object by one pixel
I've even read elsewhere on the forum that this exact method should work, that the effect should be no overlapping visibly taking place. What's happening though is that, if the object phases into a solid, it's ejected one pixel per step as if there were no loop being used. This results in quick skips or "slides" when the player overlaps a solid.
I've reduced the engine to specifically the graphics and code needed to demonstrate this, so it's easy to examine. Most of it is commented. Basically here's how it works:
The player object is surrounded by three sensors for the sides and bottom. These are used for collision testing, the player object is not. The sensors are positioned to the player in a function. This function is called every step, and also called during the while loop that's supposed to eject the player during a collision.
A separate object holds the player's variables for movement, such as x and y speed. The player's position is updated every step based on these variables.
Input group: Uses variables as proxy for input
Character Setup group: Initializes movement variables and spawns the player.
Sensor group: Holds the while loops that eject the player in the event the sensors collide with solids.
Movement groups: Handles player movement variables such as speed, gravity, assigning rendered positions to the player, and controlling the player's movement through input.
Step group: Positions the sensors to the player via image points.
Temporary Code group: Debug stuff and placeholder code for later. Doesn't do anything significant. Draws X and Y positions on screen.
The cap file is attached to the post.
Arrow keys move, Z key is jump, shift boosts x speed. Holding shift and running into walls really shows the problem here.
I would appreciate it greatly if anyone can help with this. We're rather stuck until we get past this problem.