Can SOmeone Explain THis Code
ctx.fillStyle="lime"; for(var i=0;i<trail.length;i++) { ctx.fillRect(trail[i].x*gs,trail[i].y*gs,gs-2,gs-2); if(trail[i].x==px && trail[i].y==py) { tail = 5; } } trail.push({x:px,y:py}); while(trail.length>tail) { trail.shift(); } if(ax==px && ay==py) { tail++; ax=Math.floor(Math.random()*tc); ay=Math.floor(Math.random()*tc); } ctx.fillStyle="red"; ctx.fillRect(ax*gs,ay*gs,gs-2,gs-2); } this is part of the code of snake i looked at it over and over and i still dont get it. When did they define tail as part of the snake. I dont understand it. Since they didnt define the variabel tail as part of the snake why does it make the snake grow? Since trail is the array wouldn't that make it grow bigger instead of the variable tail