Car myCar1;
Car myCar2;
Car myCar3;
Car myCar4;
Car Samson1;
Car Samson2;
Car Samson3;
Car Samson4;
Car Poop1;
Car Poop2;
Car Poop3;
Car Poop4;
Car Love1;
Car Love2;
Car Love3;
Car Love4;
Car Love5;
Car Love6;
void setup() {
size (800,500);
myCar1 = new Car(color(245,87,211,180),-200,100,8,8);
myCar2 = new Car(color(160,85,211,100),-200,200,4,-4);
myCar3 = new Car(color(130,66,149,200),-200,300,2,2);
myCar4 = new Car(color(219,15,104,100),-200,400,6,6);
Samson1 = new Car(color(160,85,211,180),1000,150,-4,-4);
Samson2 = new Car(color(219,15,104,100),1000,250,-6,-6);
Samson3 = new Car(color(130,66,149,220),1000,350,-8,-8);
Samson4 = new Car(color(245,87,211,100),1000,450,-2,-2);
Poop1 = new Car(color(234,0,153,100),-200,-150,5,2);
Poop2 = new Car(color(234,0,153,100),-300,-250,5,-10);
Poop3 = new Car(color(234,0,153,100),-400,-350,5,2);
Poop4 = new Car(color(234,0,153,100),-500,-450,5,-7);
Love1 = new Car(color(160,85,211,100),550,150,6,10);
Love2 = new Car(color(245,87,211,100),350,250,2,8);
Love3 = new Car(color(160,85,211,100),300,400,4,6);
Love4 = new Car(color(245,87,211,100),250,500,10,2);
Love5 = new Car(color(160,85,211,100),100,450,8,4);
Love6 = new Car(color(245,87,211,100),650,50,4,8);
}
void draw() {
background(239,196,252);
myCar1.drive();
myCar1.display();
myCar2.drive();
myCar2.display();
myCar3.drive();
myCar3.display();
myCar4.drive();
myCar4.display();
Samson1.driveB();
Samson1.displayB();
Samson2.driveB();
Samson2.displayB();
Samson3.driveB();
Samson3.displayB();
Samson4.driveB();
Samson4.displayB();
Poop1.driveC();
Poop1.displayC();
Poop2.driveC();
Poop2.displayC();
Poop3.driveC();
Poop3.displayC();
Poop4.driveC();
Poop4.displayC();
Love1.driveC();
Love1.displayD();
Love2.driveC();
Love2.displayD();
Love3.driveC();
Love3.displayD();
Love4.driveC();
Love4.displayD();
Love5.driveC();
Love5.displayD();
Love6.driveC();
Love6.displayD();
}
class Car {
color c;
float xpos;
float ypos;
float xspeed;
float yspeed;
Car(color tempC, float tempXpos, float tempYpos, float tempXspeed, float tempYspeed) {
c = tempC;
xpos = tempXpos;
ypos = tempYpos;
xspeed = tempXspeed;
yspeed = tempYspeed;
}
void display() {
strokeWeight(4);
stroke(255);
fill(c);
rectMode(CENTER);
rect(xpos,ypos,200,200);
}
void drive() {
xpos = xpos + xspeed;
if (xpos - 400 > width) {
xpos = -200;
}
}
void displayB() {
strokeWeight(4);
stroke(255);
fill(c);
ellipseMode(CENTER);
ellipse(xpos, ypos, 200, 200);
}
void driveB() {
xpos = xpos + xspeed;
if (xpos + 400 < 0) {
xpos = 1000;
}
}
void displayC() {
strokeWeight(4);
stroke(255);
fill(c);
rectMode(CENTER);
rect(xpos,ypos,150,150);
}
void driveC() {
ypos = ypos + yspeed;
if (ypos > height) {
ypos = 0;
}
xpos = xpos + xspeed;
if (xpos > width) {
xpos = 0;
}
}
void displayD() {
strokeWeight(4);
stroke(255);
fill(c);
ellipseMode(CENTER);
ellipse(xpos,ypos,80,80);
}
}
No comments:
Post a Comment