// Yennifer Tejada // project 8 int size = 50; float r; float g; float b; float x = 300;; float y = 540; float w = 70; float h= 40; // declare the objects from the class Ball redTejada; Ball greenTejada; Ball blueTejada; Ball randomTejada; //Button //Button[] buttons = new Button[4]; // setup for the output window void setup() { size(700, 600); r = random(255); g = random(255); b = random(255); // the three different balls redTejada = new Ball(30); greenTejada = new Ball(35); blueTejada = new Ball(25); randomTejada = new Ball(20); // // the different buttons loop // for(int i = 0; i < buttons.length; i++) // { // buttons[i] = new Button(i*90+25,height /2 + 230, 60,30); // } } // draw the background void draw() { background(18, 110, 255); stroke(3); table(); redTejada.display(); redTejada.moveHorizontal(); redTejada.moveVertical(); greenTejada.display(); greenTejada.moveHorizontal(); greenTejada.moveVertical(); blueTejada.display(); blueTejada.moveHorizontal(); blueTejada.moveVertical(); randomTejada.display(); randomTejada.moveHorizontal(); randomTejada.moveVertical(); textSize(15); fill(0); text("Project 8", 320, 20); text("Author: Yennifer Tejada", 30, 590); rect(x,y,w,h); fill(255,0,0); if(mousePressed) { if(mouseX>x && mouseX y && mouseY width - 80) { speedX = -speedX; } } void moveVertical() { // move the y-coordinates y = y + speedY; if (y < 120 || y > height - 140) { speedY = -speedY; } } } void keyPressed() { if (key == 'q') exit(); } /////////////////////////BUTTON/////////////////////////////// class Button { // declare the variables for the buttons float x; float y; float w; float h; // random RGB // float r; // float g; // float b; Button(float tejaX, float tejaY, float tejaW, float tejaH) { x = tejaX; y = tejaY; w = tejaW; h = tejaH; } void display() { rectMode(CORNER); fill(r,g,b); rect(x,y,w,h); } }