Homework 4_1

//Terrance Shields – Prof. Calli Higgins – HW 4.1 – 2/21/13

boolean square = true;
boolean ball = true;
boolean quad = true;

int bgChange = 0;

int bgColor = 255;

color green = color(28, 198, 14);
color blue = color(14, 138, 198);
color purple = color(145, 14, 198);
color white = color(255);

float x = 10; // x location of square
float y = 0; // y location of square
float bx = 0;
float by = 100;
float qx = 0;
float qy = 400;
float squareSpeed = 0; // speed of square
float ballSpeed = 3;
float quadSpeed = 1;
float gravity = 0.1;

void setup() {
size(400, 400);
smooth();
}

void draw() {
background(bgColor);

// Display the square
fill(0);
noStroke();
rectMode(CORNER);
rect(x, y, 30, 30);
fill(255, 255, 0);
ellipseMode(CORNER);
ellipse(bx, by, 40, 40);

if (square) {
x++;
y = y + squareSpeed;
squareSpeed = squareSpeed + gravity;
}
if ((x > width) || (x height) {
squareSpeed = squareSpeed * -0.95;
}
else if (!square) {
squareSpeed = 0;
}

if (ball) {
bx = bx + ballSpeed;
// If ball reaches the sides //
if ((bx > width) || (bx width) || (bx width) || (qx width) || (qx x && mouseX y && mouseY bx && mouseX by && mouseY qx && mouseX qy && mouseY 3) {
bgChange = 0;
}
}

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *