Collision Detection Moving Right/Left Through Tiles

Hey, I was wondering has anyone ran into a issue when moving left or right when collision detection occurs. For instance im almost done building a scrolling game, my player walks on the tiles perfectly, but when moving right or left, it goes through the tiles/object via collision. When theres steps/tiles in the way it goes through it verses my collision detection stopping it . Im not sure if my right/left movements are overriding each other. But when I remove the seconf KEY_RIGHT logic, the player dosent move at all.... Below is a snippet

if(IsKeyDown(KEY_RIGHT)){
player.x += 2;
camera.offset.x -= 2;
}

for(int i =0; i < MAX_FLOOR; i++){

if(CheckCollisionRecs((Rectangle){player.x,player.y,player.width,player.height},(Rectangle){platforms[i].position.x, platforms[i].position.y, platforms[i].scale.x, platforms[i].scale.y})){

player = oldPlayer;
camera = oldCamera;

if (IsKeyDown(KEY_RIGHT)){
player.x += 2;
camera.offset.x -= 2; ;

}

}
}
Sign In or Register to comment.