Guest User

Untitled

a guest
Jan 7th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. // Creating variables
  2. var myX = [], myY = [], r = [], da = [];
  3. var alpha = [];
  4. for (let i=0; i<10; ++i){
  5. alpha[i] = 0;
  6. r[i] = Math.random()*80;
  7. da[i] = Math.random()*8 - 4;
  8. }
  9. function update() {
  10. for (let i=0; i<10; ++i){
  11. alpha[i] += da[i];
  12. let rad = alpha[i]*Math.PI/180;
  13. myX[i] = Math.cos(rad)*r[i];
  14. myY[i] = Math.sin(rad)*r[i];
  15. }
  16. }
  17.  
  18. function draw() {
  19. context.beginPath();
  20. context.moveTo(400, 300);
  21. let x = 400, y = 300;
  22. for (let i=0; i<10; ++i){
  23. x += myX[i]; y += myY[i];
  24. context.lineTo(x, y);
  25. }
  26. context.stroke();
  27. // This is how you draw a rectangle
  28. };
  29.  
  30. function keyup(key) {
  31. // Show the pressed keycode in the console
  32. console.log("Pressed", key);
  33. };
  34.  
  35. function mouseup() {
  36. // Show coordinates of mouse on click
  37. console.log("Mouse clicked at", mouseX, mouseY);
  38. };
Advertisement
Add Comment
Please, Sign In to add comment