I've been working on a small game, and I've been stuck on the collision part. During the collision, when my player hits a block, he stops just as it should, but it then doesn't allow me to another direction (ex: the collision happens on the y axis, it won't allow me to move along the x axis). What I want is to be able to move along the wall while still moving into it (If you know what I mean). I've checked here and here, but they aren't what I'm looking for.
EDIT: The new code allows me to move along the axis's fine, but I'm getting some different problems (shown in pictures)
This is the NEW code for my collision detection:
if(key[KEY_A])
{
if(tileMap[(x/zoomLevel)-1][y/zoomLevel] < 1 && tileMap[(x/zoomLevel)-1][(y/zoomLevel)+1] < 1)
{
if(tileMap[((x/zoomLevel)+1)][y/zoomLevel] < 1 && tileMap[((x/zoomLevel)+1)][(y/zoomLevel)+1] < 1)
{
x-=moveSpeed;
dirX = 0;
}
}
}
else if(key[KEY_D])
{
if(tileMap[(x/zoomLevel)+1][y/zoomLevel] < 1 && tileMap[(x/zoomLevel)+1][(y/zoomLevel)+1] < 1)
{
x+=moveSpeed;
dirX = 1;
}
}
if(jumping == false)
{
if(tileMap[(x/zoomLevel)][(y/zoomLevel)+2] < 1)
{
y+=gravSpeed;
gravSpeed*1.2;
dirY = 1;
}
}
else
{
if(tileMap[(x/zoomLevel)][(y/zoomLevel)-1] < 1)
{
gravSpeed = 4;
y-=gravSpeed;
dirY = 0;
}
}
Thanks to anyone who can help me with my problem!
And here are some picture based on the new collision: