//Philip Paniccia //Project 9 boolean buttonRed= false; boolean buttonGreen= false; boolean buttonBlue= false; boolean buttonPlatform= false; int buttonX= 5; int buttonY= 5; int buttonW= 50; int buttonH= 25; Ball[] panic= new Ball[10]; Platform platPanic; /* Button redButPanic; Button greenButPanic; Button blueButPanic; Button changeButPanic; */ int nb; Button[] philip; void setup(){ size(500,500); panic[0]= new Ball(color(255,0,0)); panic[1]= new Ball(color(0,255,0)); panic[2]= new Ball(color(0,0,255)); panic[3]= new Ball(color(50)); panic[4]= new Ball(color(100)); panic[5]= new Ball(color(150)); panic[6]= new Ball(color(200)); panic[7]= new Ball(color(255)); panic[8]= new Ball(color(175)); panic[9]= new Ball(0); platPanic= new Platform(color(0,0,100)); /* redButPanic= new Button(color(255,0,0), 5,5); greenButPanic= new Button(color(0,255,0), 100,5); blueButPanic= new Button(color(0,0,255), 200,5); changeButPanic= new Button(color(0), 300,5); */ nb= (width-1)/ 100; nb= nb + 3; philip= new Button[nb]; philip[0]= new Button(color(255,0,0), 5,5); philip[1]= new Button(color(0,255,0), 100,5); philip[2]= new Button(color(0,0,255), 200,5); philip[3]= new Button(color(0), 300,5); philip[4]= new Button(color(255), 400,5); } void draw(){ background(175); /* redButPanic.display(); greenButPanic.display(); blueButPanic.display(); changeButPanic.display(); */ platPanic.display(); for (int j=0; j width-50) || (ballX < 62)){ ballDX= -ballDX; } if ((ballY > height-50) || (ballY < 62)){ ballDY= -ballDY; } } void randomize(){ ballX = 110 + random ( 110 ); ballY = 110 + random ( 110 ); ballDX = 1 + random ( 11 ); ballDY = 1 + random ( 11 ); } } class Platform{ //background of where balls bounce color platformC; float platformX; float platformY; float platformW; float platformH; //constructor Platform(color tempPlatformC){ platformC= tempPlatformC; platformX= 50; platformY= 50; platformW= 415; platformH= 415; } void display(){ //build Platform noStroke(); if(buttonPlatform){ noStroke(); fill(0,100,0); rect(50,50, 415,415); }else{ fill(platformC); rect(platformX, platformY, platformW, platformH); } } } class Button{ //buttons will restart balls, and change platform color color buttonC; float buttonX; float buttonY; float buttonW; float buttonH; //constructor Button(color tempButtonC, float tempButtonX, float tempButtonY){ buttonC= tempButtonC; buttonX= tempButtonX; buttonY= tempButtonY; buttonW= 50; buttonH= 25; } void display(){ //show buttons noStroke(); fill(buttonC); rect(buttonX, buttonY, buttonW, buttonH); buttonRed= false; buttonGreen= false; buttonBlue= false; } boolean hit(float xx, float yy){ return(xx>buttonX && xxbuttonY && yy buttonX+295 && mouseX < buttonX+295+buttonW && mouseY > buttonY && mouseY < buttonY+buttonH) { buttonPlatform= !buttonPlatform; } }