Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(key == "esc"){//exit
- // ...
- }
- if(key == "left" || key == "up" || key == "down" || key == "right"){//newt move
- // ...
- }
- if(key == "left")px-=step;
- if(key == "right")px+=step;
- if(key == "up")py-=step;
- if(key == "down")py+=step;
- if(px<0)px = canvas.width-step;//new head position
- if(py<0)py = canvas.height-step;
- if(px>canvas.width-step)px = 0;
- if(py>canvas.height-step)py = 0;
- for(var i = 1; i < tail; i++){
- // ...
- }
- while(mealy%step){
- mealy+=1;
- }
- while (mealy % step) {
- mealy += 1;
- }
- if(bigHead == 0){//drawing head
- ctx.fillStyle = "lime";
- ctx.fillRect(pos[0][0], pos[0][1], step-brd, step-brd);
- ctx.fillStyle = "DarkGreen";
- ctx.fillRect(pos[0][0]+step/7, pos[0][1]+step/7, step/1.8, step/1.8 );
- }else{
- ctx.fillStyle = "yellow";
- ctx.fillRect(pos[0][0], pos[0][1], step-brd, step-brd);
- ctx.fillStyle = "red";
- ctx.fillRect(pos[0][0]+step/7, pos[0][1]+step/7, step/1.8, step/1.8 );
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement