Assignment2_Colourgenn

Colour Gen on Key Press

5.jpg

Screen shot

--

Processing Code

int Length = 400;
int Width = 600;

void setup()
{
size (Width, Length);
background(0,0,0);
}

int value =255;

void draw() {
fill(255);
rect(0, 200, 200, 200);
fill(255);
rect(400, 200, 200, 200);
fill(255);
rect(200, 0, 200, 200);
fill(255);
rect(200, 200, 200, 200);

if(keyPressed) {
if (key == 'a' || key == 'A') {
fill(255,0,0);
}
/*else {
fill(255);
}*/

rect(200, 200, 200, 200);

if (key == 's' || key == 'S') {
fill(0,255,0);
rect(400, 200, 200, 200);
}
/*else {
fill(255);
}*/
//rect(0, 200, 200, 200);

if (key == 'd' || key == 'D') {
fill(0,0,255);
}
else {
fill(255);
}
rect(200, 00, 200, 200);

if (key == 'w' || key == 'W') {
fill(255,255,0);
}
else {
fill(255);
}
rect(0, 200, 200, 200);
}
//fill(255);

}

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License