float x = 100;
float y = 0;
float speed = 0;
float gravity = 0.1;
boolean movingRight = true;
boolean movingLeft = false;
float xPos = 1;
void setup() {
size(400, 400);
smooth();
}
void draw() {
noCursor();
background(90);
//Floor
fill(80);
rect(0, 300, 400, 200);
//Conditionals
bounce();
callGravity();
resturant();
ball();
waitor();
paddle();
}
void bounce() {
// println(xPos);
if (movingRight && xPos < 375) {
xPos++;
} else {
movingRight = false;
movingLeft = true;
}
if (movingLeft && xPos > 0) {
xPos--;
} else {
movingRight = true;
movingLeft = false;
}
}
void callGravity() {
y = y + speed;
xPos = xPos + 0.1;
speed = speed + gravity;
if (y > height) {
speed = speed * -0.95;
}
}
void resturant() {
//Trim
fill(120);
rect(0,300,400,5);
//Chair#1
fill(60);
rect(80, 200, 10, 120);
rect(80, 260, 50, 20);
rect(120, 260, 10, 60);
//Person#1
fill(89, 104, 116);
rect(90, 190, 20, 70);
rect(130, 260, 20, 60);
ellipse(120, 170, 40, 40);
rect(110, 210, 30, 10);
//Chair#2
fill(60);
rect(240, 200, 10, 120);
rect(200, 260, 50, 20);
rect(200, 260, 10, 60);
//Person#2
fill(70);
rect(220, 190, 20, 70);
rect(180, 260, 20, 60);
ellipse(210, 170, 40, 40);
rect(190, 210, 30, 10);
//Table
noStroke();
fill(201);
rect(110, 220, 110, 50);
fill(180);
triangle(110, 220, 100, 260, 110, 260);
triangle(220, 220, 220, 260, 230, 260);
fill(100);
rect(150, 270, 30, 10);
rect(160, 280, 10, 30);
rect(150, 310, 30, 10);
//Chair#3
fill(60);
rect(330, 200, 10, 120);
rect(330, 260, 50, 20);
rect(370, 240, 10, 80);
//Person#4
fill(70);
rect(340, 190, 20, 70);
rect(380, 270, 20, 50);
ellipse(370, 170, 40, 40);
rect(360, 210, 30, 10);
//table
fill(201);
rect(360, 220, 40, 50);
fill(180);
triangle(360,220, 360,260, 350,260);
//Light
fill(120);
rect(160, 20, 10, 20);
quad( 160,20, 170,20, 190,40, 140,40);
triangle(400,20, 390,40, 400,40);
fill(80);
rect(160, 40, 10, 5);
quad(164,0, 166,0, 164,20, 166,20);
}
void ball() {
noStroke();
fill(255);
ellipse(xPos, y, 50, 50);
}
void waitor() {
//Waitor
noStroke();
//Head
fill(50);
ellipse(60 + mouseX, 120, 40, 40);
//Hands
fill(50);
rect(30+ mouseX, 180, 10, 10);
rect(110+ mouseX, 120, 10, 10);
//Chest
fill(200);
rect(40+ mouseX, 140, 40, 80);
//Tie
fill(180, 69, 69);
quad(60+ mouseX, 140, 55+ mouseX, 170, 60+ mouseX, 180, 65+ mouseX, 170);
//Arms
fill(200);
quad(40+ mouseX, 140, 50+ mouseX, 150, 20+ mouseX, 180, 10+ mouseX, 170);
quad(20+ mouseX, 160, 10+ mouseX, 170, 30+ mouseX, 190, 40+ mouseX, 180);
quad(80+ mouseX, 140, 120+ mouseX, 140, 120+ mouseX, 150, 80+ mouseX, 160);
rect(110+ mouseX, 130, 10, 20);
//waist
fill(50);
rect(40+ mouseX, 200, 40, 20);
//Legs
fill(50);
rect(40+ mouseX, 200, 10, 120);
rect(70+ mouseX, 200, 10, 120);
//Belt
fill(60);
rect(40+ mouseX, 200, 40, 10);
//Feet
fill(50);
triangle(40+ mouseX, 310, 40+ mouseX, 320, 30+ mouseX, 320);
triangle(80+ mouseX, 310, 80+ mouseX, 320, 90+ mouseX, 320);
}
void paddle() {
fill(214);
rect(mouseX + 90, 115, 55, 5);
if (y > 90) {
if (xPos <= mouseX + 300 && xPos >= mouseX +10) {
//bounce
speed = speed * -0.95;
}
}
}