Sorry I can not.
If I explain something I make sure I explain it so people really understand it.
THIS METHOD IS NOT FINISHED YET I NEED TO OPTIMIZE IT FOR MY PURPOSE AND WORK OUT THE BUGS.
Prototype.swf (54.4 KB)
My idea was to check if I have collision on one of the 4 sides, If one side got collided with a tile then change the player in that color for debugging purposes and move the player in a direction.
If it reached a corner it will stop colliding because… it is not colliding with anything. If this happens I will move the player 1 pixel down if the last collision was pink. and If the last collision was red I move it 1px to the left if it reaches another corner and so on and so on.
Then I will reset the 4 sides collision booleans (eg: pink is true, all others are false. reach corner will reset all 4 sides including the current pink one.)
This idea currently only works for straight platforms but I need to make it work for all my purposes. Tomorrow I will proceed with this idea and make it better.
IT WOULD BE BAD TO COPY MY CRAPPY CODE, JUST USE IT TO GET THE CONCEPT BEHIND IT.
Code:
private var _velocity:Point;
private var leftV:Boolean;
private var rightV:Boolean;
private var topV:Boolean;
private var bottomV:Boolean;
_velocity = new Point;
var movement:Point = new Point;
//if (Input.check(Key.LEFT)) movement.x--;
//if (Input.check(Key.RIGHT)) movement.x++;
//if (Input.check(Key.UP)) movement.y--;
//if (Input.check(Key.DOWN)) movement.y++;
if (leftV) movement.y++;
if (topV) movement.x--;
if (rightV) movement.y--;
if (bottomV) movement.x++;
_velocity.x = 50 * FP.elapsed * movement.x;
_velocity.y = 50 * FP.elapsed * movement.y;
x += _velocity.x;
y += _velocity.y;
// Top-Left
if (collide("Level",x-width, y))
{
// Left
Image(this.graphic).color = 0xffff0000;
leftV = true;
rightV = false;
topV = false;
bottomV = false
}else if (collide("Level",x+width, y))
{
// Right
Image(this.graphic).color = 0xfffff600;
rightV = true;
leftV = false;
topV = false;
bottomV = false
}else if (collide("Level",x, y-height))
{
// Top
Image(this.graphic).color = 0xff0036ff;
topV = true;
leftV = false;
rightV = false;
bottomV = false
}else if (collide("Level",x, y+height))
{
// Bottom
Image(this.graphic).color = 0xffff00cc;
bottomV = true;
leftV = false;
rightV = false;
topV = false;
}
else
{
Image(this.graphic).color = 0xffffffff;
if (leftV && !rightV && !topV && !bottomV) {
trace("Red/Left last check");
moveBy(-1, 0);
}
if (!leftV && rightV && !topV && !bottomV) {
trace("Yellow/Right last check");
moveBy(1, 0);
}
if (!leftV && !rightV && topV && !bottomV) {
trace("Blue/Top last check");
moveBy(0, -1);
}
if (!leftV && !rightV && !topV && bottomV) {
trace("Pink/bottom last check");
moveBy(0, 1);
}
leftV = false;
rightV = false;
topV = false;
bottomV = false;
}
Have fun.
In the end my good old brain was better than anything I could find on the internet… which was nothing