A square tile collides with another square tile. The bartender says...
I have:
if(player.y <= wall.y + wall.height && player.y > wall.y || player.y + player.height <= wall.y+wall.height && player.y + player.height > wall.y){
if(player.x -2< wall.x + wall.width && player.x > wall.x){
leftspeed = 0
}else if(player.x + player.width +2 > wall.x && player.x + player.width < wall.x + wall.width){
rightspeed = 0
}
}
if(player.x <= wall.x + wall.width && player.x > wall.x || player.x + player.width <= wall.x+wall.width && player.x + player.width > wall.x){
if(player.y -2 < wall.y + wall.height && player.y > wall.y){
upspeed = 0
}else if(player.y + player.height +2> wall.y && player.y + player.height < wall.y + wall.height){
downspeed = 0
}
}
this should work, there is a 2 pixel margin around everything that you may want to remove