Advertisement
Guest User

Untitled

a guest
May 28th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. var armSize = 50;
  2. var posX = 0;
  3. var posY = 0;
  4.  
  5. var current = 0;
  6.  
  7. function drawArm()
  8. {
  9. var send = [];
  10. if(current == 0)
  11. { // upper left
  12. send.push({x: posX + 0, y: posY + 0});
  13.  
  14. send.push({x: posX + 0, y: posY + armSize});
  15.  
  16. send.push({x: posX + armSize, y: posY + armSize});
  17.  
  18. }
  19.  
  20. if(current == 1)
  21. { // upper right
  22. send.push({x: posX + armSize * 2, y: posY + 0});
  23.  
  24. send.push({x: posX + armSize, y: posY + 0});
  25.  
  26. send.push({x: posX + armSize, y: posY + armSize});
  27.  
  28. }
  29.  
  30. if(current == 2)
  31. { // lower right
  32. send.push({x: posX + armSize * 2, y: posY + armSize * 2});
  33. send.push({x: posX + armSize * 2, y: posY + armSize});
  34. send.push({x: posX + armSize, y: posY + armSize});
  35. }
  36.  
  37. if(current == 3)
  38. { // lower left
  39. send.push({x: posX + 0, y: posY + armSize * 2});
  40. send.push({x: posX + armSize, y: posY + armSize * 2});
  41. send.push({x: posX + armSize, y: posY + armSize});
  42. }
  43.  
  44. if(current == 4)
  45. {
  46. // randomize posX, posY, set timeout and return
  47. posX = Math.floor(Math.random() * 1200);
  48. posY = Math.floor(Math.random() * 700);
  49. current = 0;
  50. setTimeout(drawArm, 100);
  51. return;
  52. }
  53.  
  54. socket.emit('update', { points: send, color: color, id: 1 });
  55.  
  56. current++;
  57. drawArm();
  58. }
  59. drawArm();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement