//////////////////////COLOR CHANGER///////////////////////
/////////////////////BY DYLAN SOUKSOMBATH//////////////////////
//////////////////////////////////////////////////////////
//MOVE THE BALL WITH UP, DOWN, LEFT, AND RIGHT KEYS TO CHANGE THE SQUARES COLOR.//
//THERE ARE 16 COLORS IN TOTAL TO MOVE AROUND TO//
//classes
Ball ball;
Square square;
//set up canvas
void setup() {
size(400, 400);
ball = new Ball();
square = new Square();
}
//draw background and objects
void draw() {
background(0);
ball.drawBall();
square.drawSquare();
}
//makes it so that the ball moves with the UP,DOWN,LEFT,and RIGHT keys.
void keyPressed() {
if (keyCode == UP) {
ball.ballPosition.y-=10;
} else if (keyCode == DOWN) {
ball.ballPosition.y+=10;
} else if (keyCode == RIGHT) {
ball.ballPosition.x+=10;
} else if (keyCode == LEFT) {
ball.ballPosition.x-=10;
}
}class Ball {
//set values for the ball to draw upon
PVector ballPosition = new PVector (width/2,height/2);
void drawBall() {
//draw the ball
fill(255);
ellipse(ballPosition.x, ballPosition.y, 50, 50);
}
}
class Square {
//variables
float x = random(50,350);
float y = random(50,350);
float[] colorSet1 = new float[3];
float[] colorSet2 = new float[3];
float[] colorSet3 = new float[3];
float[] colorSet4 = new float[3];
float[] colorSet5 = new float[3];
float[] colorSet6 = new float[3];
float[] colorSet7 = new float[3];
float[] colorSet8 = new float[3];
float[] colorSet9 = new float[3];
float[] colorSet10 = new float[3];
float[] colorSet11 = new float[3];
float[] colorSet12 = new float[3];
float[] colorSet13 = new float[3];
float[] colorSet14 = new float[3];
float[] colorSet15 = new float[3];
float[] colorSet16 = new float[3];
void drawSquare() {
//set integers for RGB fill for light blue quadrant
colorSet1[0] = 150;
colorSet1[1] = 200;
colorSet1[2] = 250;
//set integers for RGB fill for pink quadrant
colorSet2[0] = 250;
colorSet2[1] = 150;
colorSet2[2] = 200;
//set integers for RGB fill for light green quadrant
colorSet3[0] = 200;
colorSet3[1] = 250;
colorSet3[2] = 150;
//set integers for RGB fill for dark blue quadrant
colorSet4[0] = 100;
colorSet4[1] = 100;
colorSet4[2] = 255;
//set integers for RGB fill for red quadrant
colorSet5[0] = 255;
colorSet5[1] = 100;
colorSet5[2] = 100;
//set integers for RGB fill for purple quadrant
colorSet6[0] = 200;
colorSet6[1] = 150;
colorSet6[2] = 250;
//set integers for RGB fill for teal quadrant
colorSet7[0] = 150;
colorSet7[1] = 250;
colorSet7[2] = 200;
//set integers for RGB fill for teal quadrant
colorSet8[0] = 250;
colorSet8[1] = 200;
colorSet8[2] = 150;
//set integers for RGB fill for green quadrant
colorSet9[0] = 100;
colorSet9[1] = 230;
colorSet9[2] = 90;
//set integers for RGB fill for blue quadrant
colorSet10[0] = 50;
colorSet10[1] = 150;
colorSet10[2] = 255;
//set integers for RGB fill for dark purple quadrant
colorSet11[0] = 150;
colorSet11[1] = 50;
colorSet11[2] = 250;
//set integers for RGB fill for brown quadrant
colorSet12[0] = 180;
colorSet12[1] = 150;
colorSet12[2] = 130;
//set integers for RGB fill for burgundy quadrant
colorSet13[0] = 100;
colorSet13[1] = 20;
colorSet13[2] = 40;
//set integers for RGB fill for dark green quadrant
colorSet14[0] = 40;
colorSet14[1] = 100;
colorSet14[2] = 20;
//set integers for RGB fill for dark blue quadrant
colorSet15[0] = 20;
colorSet15[1] = 40;
colorSet15[2] = 100;
//set integers for RGB fill for dark blue quadrant
colorSet16[0] = 150;
colorSet16[1] = 50;
colorSet16[2] = 100;
fill(255);
//light blue quadrant
if (ball.ballPosition.x >= 0 && ball.ballPosition.x <= 100)
if (ball.ballPosition.y >=0 && ball.ballPosition.y <= 100){
fill(colorSet1[0],colorSet1[1],colorSet1[2]);
}
//pink quadrant
if (ball.ballPosition.x >= 100 && ball.ballPosition.x <= 200)
if (ball.ballPosition.y >=0 && ball.ballPosition.y <= 100){
fill(colorSet2[0],colorSet2[1],colorSet2[2]);
}
//light green quadrant
if (ball.ballPosition.x >= 200 && ball.ballPosition.x <= 300)
if (ball.ballPosition.y >=0 && ball.ballPosition.y <= 100){
fill(colorSet3[0],colorSet3[1],colorSet3[2]);
}
//dark blue quadrant
if (ball.ballPosition.x >= 300 && ball.ballPosition.x <= 400)
if (ball.ballPosition.y >=0 && ball.ballPosition.y <= 100){
fill(colorSet4[0],colorSet4[1],colorSet4[2]);
}
//red quadrant
if (ball.ballPosition.x >= 0 && ball.ballPosition.x <= 100)
if (ball.ballPosition.y >=100 && ball.ballPosition.y <= 200){
fill(colorSet5[0],colorSet5[1],colorSet5[2]);
}
//purple quadrant
if (ball.ballPosition.x >= 100 && ball.ballPosition.x <= 200)
if (ball.ballPosition.y >=100 && ball.ballPosition.y <= 200){
fill(colorSet6[0],colorSet6[1],colorSet6[2]);
}
//teal quadrant
if (ball.ballPosition.x >= 200 && ball.ballPosition.x <= 300)
if (ball.ballPosition.y >=100 && ball.ballPosition.y <= 200){
fill(colorSet7[0],colorSet7[1],colorSet7[2]);
}
//orange quadrant
if (ball.ballPosition.x >= 300 && ball.ballPosition.x <= 400)
if (ball.ballPosition.y >=100 && ball.ballPosition.y <= 200){
fill(colorSet8[0],colorSet8[1],colorSet8[2]);
}
//green quadrant
if (ball.ballPosition.x >= 0 && ball.ballPosition.x <= 100)
if (ball.ballPosition.y >=200 && ball.ballPosition.y <= 300){
fill(colorSet9[0],colorSet9[1],colorSet9[2]);
}
//blue quadrant
if (ball.ballPosition.x >= 100 && ball.ballPosition.x <= 200)
if (ball.ballPosition.y >=200 && ball.ballPosition.y <= 300){
fill(colorSet10[0],colorSet10[1],colorSet10[2]);
}
//dark purple quadrant
if (ball.ballPosition.x >= 200 && ball.ballPosition.x <= 300)
if (ball.ballPosition.y >=200 && ball.ballPosition.y <= 300){
fill(colorSet11[0],colorSet11[1],colorSet11[2]);
}
//brown quadrant
if (ball.ballPosition.x >= 300 && ball.ballPosition.x <= 400)
if (ball.ballPosition.y >=200 && ball.ballPosition.y <= 300){
fill(colorSet12[0],colorSet12[1],colorSet12[2]);
}
//burgundy quadrant
if (ball.ballPosition.x >= 0 && ball.ballPosition.x <= 100)
if (ball.ballPosition.y >=300 && ball.ballPosition.y <= 400){
fill(colorSet13[0],colorSet13[1],colorSet13[2]);
}
//dark green quadrant
if (ball.ballPosition.x >= 100 && ball.ballPosition.x <= 200)
if (ball.ballPosition.y >=300 && ball.ballPosition.y <= 400){
fill(colorSet14[0],colorSet14[1],colorSet14[2]);
}
//dark blue quadrant
if (ball.ballPosition.x >= 200 && ball.ballPosition.x <= 300)
if (ball.ballPosition.y >=300 && ball.ballPosition.y <= 400){
fill(colorSet15[0],colorSet15[1],colorSet15[2]);
}
//dark blue quadrant
if (ball.ballPosition.x >= 300 && ball.ballPosition.x <= 400)
if (ball.ballPosition.y >=300 && ball.ballPosition.y <= 400){
fill(colorSet16[0],colorSet16[1],colorSet16[2]);
}
rect(x, y, 50, 50);
}
}