Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. if(key == "esc"){//exit
  2. // ...
  3. }
  4. if(key == "left" || key == "up" || key == "down" || key == "right"){//newt move
  5. // ...
  6. }
  7.  
  8. if(key == "left")px-=step;
  9. if(key == "right")px+=step;
  10. if(key == "up")py-=step;
  11. if(key == "down")py+=step;
  12.  
  13. if(px<0)px = canvas.width-step;//new head position
  14. if(py<0)py = canvas.height-step;
  15. if(px>canvas.width-step)px = 0;
  16. if(py>canvas.height-step)py = 0;
  17.  
  18. for(var i = 1; i < tail; i++){
  19. // ...
  20. }
  21.  
  22. while(mealy%step){
  23. mealy+=1;
  24. }
  25.  
  26. while (mealy % step) {
  27. mealy += 1;
  28. }
  29.  
  30. if(bigHead == 0){//drawing head
  31. ctx.fillStyle = "lime";
  32. ctx.fillRect(pos[0][0], pos[0][1], step-brd, step-brd);
  33. ctx.fillStyle = "DarkGreen";
  34. ctx.fillRect(pos[0][0]+step/7, pos[0][1]+step/7, step/1.8, step/1.8 );
  35. }else{
  36. ctx.fillStyle = "yellow";
  37. ctx.fillRect(pos[0][0], pos[0][1], step-brd, step-brd);
  38. ctx.fillStyle = "red";
  39. ctx.fillRect(pos[0][0]+step/7, pos[0][1]+step/7, step/1.8, step/1.8 );
  40. // ...
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement