kes[i].x,snakes[i].y+BLOCK_SIZE);c.closePath();c.strokeStyle="white";c.stroke();10}4.1.3食物的出现//画出食物c.beginPath();c.fillStyle="yellow";//食物的颜色是黄色c.fillRect(foodX,foodY,BLOCK_SIZE,BLOCK_SIZE);c.moveTo(foodX,foodY);c.o(foodX+BLOCK_SIZE,foodY);c.o(foodX+BLOCK_SIZE,foodY+BLOCK_SIZE);c.o(foodX,foodY+BLOCK_SIZE);c.closePath();c.strokeStyle="red";c.stroke();}4.1.4游戏初始化//游戏初始化functionstart(){for(vari=0;i<snakecount;i++){snakes[i]={x:i*BLOCK_SIZE,y:0};}addFood();draw();oMark.innerHTML=0;}4.1.5控制蛇的移动模块//移动函数functionmove(){switch(toGo){case1://左边snakes.push({x:snakes[snakecount-1].x-BLOCK_SIZE,y:snakes[snakecount-1].y});break;case2://上边snakes.push({x:snakes[snakecount-1].x,y:snakes[snakecount-1].y-BLOCK_SIZE});break;case3://右边snakes.push({x:snakes[snakecount-1].x+BLOCK_SIZE,y:snakes[snakecount-1].y});