Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Circle myCircle;
- void setup(){
- size(200,200);
- myCircle = new Circle();
- }
- void draw(){
- background(55);
- myCircle.display();
- myCircle.drive();
- }
- class Circle {
- color c;
- float xpos;
- float ypos;
- float xspeed;
- float circleWidth;
- float circleHeight;
- float speed = 1.05;
- int direction = 1;
- Circle() {
- c = color(140,255,100,100);
- xpos = width/2;
- ypos = height/2;
- circleWidth = 10;
- circleHeight = 10;
- xspeed = 1;
- }
- void display() {
- ellipseMode(CENTER);
- fill(c);
- if (circleHeight > width || circleWidth > height){
- direction *= -1;}
- if (circleHeight < 0 || circleWidth < 0){
- direction *= -1;
- }
- circleWidth += speed * direction;
- circleHeight += speed * direction;
- ellipse(xpos,ypos,circleWidth,circleHeight);
- }
- void drive() {
- if (xpos >=200){
- xpos = xpos + 1;
- ypos = ypos + 1;
- }
- xpos = 5;
- ypos = 5;
- xpos = xpos + xspeed;
- ellipse(xpos,ypos,circleWidth,circleHeight);
- }
- }
- //if (circleY > 200); {
- // circleY= 1;
- //};
- //ellipse(mouseX+40,mouseY+20,50,50);
- // ellipse(mouseX+90,mouseY+20,50,50);
- //ellipse(mouseX+60,mouseY+15,60,60);
- //line(mouseX+65,mouseY+95,mouseX+40,mouseY+45);
- //line(mouseX+65,mouseY+95,mouseX+90,mouseY+45);
- // line(mouseX+40,mouseY+130,mouseX+40,mouseY+10);
- // line(mouseX+87,mouseY+130,mouseX+90,mouseY+10);
Add Comment
Please, Sign In to add comment