Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. class Border
  2. {
  3. constructor(width, height, num1, num2, speed)
  4. {
  5.  
  6. this.height = height;
  7. this.width = width;
  8. this.x = 0;
  9. this.myrand = random(num1,num2);
  10.  
  11. }
  12.  
  13. reveal()
  14. {
  15.  
  16. rect(this.x,this.myrand,this.height,this.width);
  17.  
  18. }
  19.  
  20. along(speed)
  21. {
  22. speed = speed;
  23. this.x += speed;
  24. if(this.x >= 600)
  25. {
  26. this.x = 0;
  27. }
  28.  
  29. }
  30.  
  31. RandomSpawnRange(num1, num2)
  32. {
  33.  
  34. if(this.x >= 590)
  35. {
  36. this.myrand = random(num1, num2);
  37.  
  38. }
  39.  
  40. }
  41.  
  42. }
  43.  
  44. class Player
  45. {
  46.  
  47. constructor(x,y,diam)
  48. {
  49.  
  50. this.x = x;
  51. this.y = y;
  52. this.diam = diam;
  53.  
  54.  
  55. }
  56.  
  57. reveal()
  58. {
  59.  
  60. ellipse(this.x, this.y, this.diam);
  61.  
  62.  
  63. }
  64.  
  65. lol()
  66. {
  67.  
  68. this.x = 5000;
  69. }
  70.  
  71. along(position)
  72. {
  73.  
  74. this.y = mouseY;
  75. this.x = mouseX;
  76. noCursor();
  77.  
  78. }
  79.  
  80. }
  81.  
  82. function setup() {
  83. createCanvas(600, 600);
  84. x = new Border(100,20, 0, 500);
  85. y = new Player(550,50,50);
  86. }
  87.  
  88. function draw() {
  89. background(1);
  90. x.reveal();
  91. x.along(5)
  92. x.RandomSpawnRange(0,500,10);
  93. y.reveal();
  94. y.along();
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement