Guest User

Untitled

a guest
Feb 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. Circle myCircle;
  2.  
  3. void setup(){
  4. size(200,200);
  5. myCircle = new Circle();
  6. }
  7.  
  8.  
  9.  
  10. void draw(){
  11.  
  12. background(55);
  13. myCircle.display();
  14. myCircle.drive();
  15.  
  16. }
  17.  
  18. class Circle {
  19.  
  20. color c;
  21. float xpos;
  22. float ypos;
  23. float xspeed;
  24. float circleWidth;
  25. float circleHeight;
  26. float speed = 1.05;
  27. int direction = 1;
  28.  
  29. Circle() {
  30. c = color(140,255,100,100);
  31. xpos = width/2;
  32. ypos = height/2;
  33. circleWidth = 10;
  34. circleHeight = 10;
  35. xspeed = 1;
  36. }
  37.  
  38. void display() {
  39. ellipseMode(CENTER);
  40. fill(c);
  41.  
  42. if (circleHeight > width || circleWidth > height){
  43.  
  44. direction *= -1;}
  45.  
  46. if (circleHeight < 0 || circleWidth < 0){
  47.  
  48. direction *= -1;
  49. }
  50.  
  51. circleWidth += speed * direction;
  52. circleHeight += speed * direction;
  53.  
  54. ellipse(xpos,ypos,circleWidth,circleHeight);
  55. }
  56.  
  57. void drive() {
  58.  
  59. if (xpos >=200){
  60.  
  61.  
  62. xpos = xpos + 1;
  63. ypos = ypos + 1;
  64. }
  65. xpos = 5;
  66. ypos = 5;
  67. xpos = xpos + xspeed;
  68. ellipse(xpos,ypos,circleWidth,circleHeight);
  69.  
  70. }
  71.  
  72. }
  73.  
  74.  
  75.  
  76.  
  77.  
  78. //if (circleY > 200); {
  79. // circleY= 1;
  80. //};
  81. //ellipse(mouseX+40,mouseY+20,50,50);
  82. // ellipse(mouseX+90,mouseY+20,50,50);
  83. //ellipse(mouseX+60,mouseY+15,60,60);
  84. //line(mouseX+65,mouseY+95,mouseX+40,mouseY+45);
  85. //line(mouseX+65,mouseY+95,mouseX+90,mouseY+45);
  86. // line(mouseX+40,mouseY+130,mouseX+40,mouseY+10);
  87. // line(mouseX+87,mouseY+130,mouseX+90,mouseY+10);
Add Comment
Please, Sign In to add comment