Collision detection made more simple?
When I try to program collision detection in games, I always end up doing it in quite a cumbersome way. Consider the following code: //Up } else if(mouseX > 60 && mouseX < 100 && mouseY > 360 && mouseY < 400 && this.y > wall.y + wall.h || mouseX > 60 && mouseX < 100 && mouseY > 360 && mouseY < 400 && this.y < wall.y || mouseX > 60 && mouseX < 100 && mouseY > 360 && mouseY < 400 && this.x < wall.x - 20 || mouseX > 60 && mouseX < 100 && mouseY > 360 && mouseY < 400 && this.x > wall.x + wall.w) { this.y -= 5; That is my code for making sure my player doesn’t move through a wall object when pressing the up key(!). This I have to repeat for every key (oh gawd). There’s got to be a simpler, less verbose way to do this, right?