I\'m trying to make a snake game in javascript, but I am struggling with collision detection. I\'ve tried various methods so far, but in desperation, have settled storing all th
You function here needs a little work and it may fix your problem.
this.collide = function(){
for(var z=0; z<this.positions.length-1; z++){
for(var q=z+1; q<this.positions.length-1; q++){
return this.positions[z][0] == this.positions[q][0] && this.positions[z][1] == this.positions[q][1];
}
}
}
2 things are wrong.
Looks cool. Lets see Mario next ;)