EDIT: Problem solved
I have made a lot of progress in my game recently. One thing that I need help with is moving up a slope.
In my game, the tiles are pixels, stored as an 2d array char: 0 is hollow, 1 is solid.
Look at these pictures below, the brown square are solid(1) and the gray is hollow(0). The black grids are pixels.
[attachment=13765:acceptable1.png]
[attachment=13766:acceptable2.png]
[attachment=13767:acceptable3.png]
In these three cases, I would move up when standing in front of the slope.
In these two cases, it would be threated as a wall, because the slope is two pixels high, anything that exceeds one count as a wall.
[attachment=13768:notacceptable1.png]
[attachment=13769:notacceptable2.png]
I implemented this before. All I did was to check if there was an slope in front of me, and it were, increased the height of the character. This did not work well with the running mechanism. When I start run faster, I do not increase one step per frame, it could be like 5 pixels per frame.
So the slope-check always failed in high speed. Even when it worked,
This is the piece of code that executes when the left left key is down
if(the left key is down)
{
if(vx < maxX) //Check so I dont surpass the max speed.
vx += accX * DELTA;
float nextX = currX - vx * DELTA;
if(canGoToLeft(nextX)) //Test if I can go to the possible next X position.
moveTo(nextX, currY);
else //I have most likely ran into an wall, so set vx to 0.
vx = 0;
}
The one for right key is similar.