Hello friends,
I created a simple game that has an annoying bug that I can not solve /
may be simple for some of you but my brain has become mashed and I can no longer think of a logical solution.
So the goal in the game is to eat as many white squares per minute and be careful of the red squares, eating three red squares will end the game. Navigation is performed using the arrow keys on the keyboard.
Now, if you invest a minute or two you will see that my test of Collusion not always working.
its in lines 217 (for good squeres) and 251 (for the bad ones).
I would really appreciate from the bottom of my heart for anyone who can take a look.
Thanks!
specific function (what am i missing here?)
//CHECK COLLUSION FUNCTION
this.checkCollusion = function(player) {
if (this.pos.x >= player.pos.x && this.pos.x <= player.pos.x + player.size &&
this.pos.y >= player.pos.y && this.pos.y <= player.pos.y + player.size ||
this.pos.x + this.size >= player.pos.x && this.pos.x + this.size <= player.pos.x + player.size &&
this.pos.y + this.size <= player.pos.y + player.size && this.pos.y >= player.pos.y) {
return true;
} else {
return false;
}