Homework for 11/7/2023
Still want to add a third part to the left of the screen and more things to interact with.
Right now you can create the hat by pressing any mouse button and holding it, and turn on and off the stop light by pressing any button on the key board.
I might create an image to use as the background instead of just using a color.
My code so far:
function setup() {
createCanvas(1280, 720);
}
let rvalue = 0;
let gvalue = 0;
let bvalue = 0;
function draw() {
background(197,181,230,90);
if(mouseIsPressed == true)
{
// Draw the party hat
fill(224, 84, 180); // hat color
triangle(600, 100, 650, 250, 550, 250);
// Draw polka dots
fill(255,255,255)//white colorlor
circle(580, 200, 20);
circle(620, 215, 15);
circle(590, 230, 20);
circle(600, 160, 20);
// Draw the pom
fill(255,255,0)
circle(600, 100,40)
}
//draw the face
fill(255, 255, 0); // Yellow color for the face
strokeWeight(8);
circle(600, 400, 300);
//draw the eyes
fill(0); // Black color for the eyes
ellipse(550, 350, 60 , 100);
ellipse(650, 350, 60, 100);
//draw the mouth
noFill();
stroke(0);
arc(600, 440, 150, 100, 0, PI);
////////////////////////////
//stop light base
fill(222, 185, 100)
strokeWeight(10)
rect(1000, 100, 250, 600)
//stop light red
fill(rvalue, 0, 0); //rvalue is 0 when the lights are black and 255 when light is on showing red
circle(1125, 225, 150);
//stop light yellow
fill(rvalue, gvalue, 0); //rvalue and gvalue are 0 when black and 255 each when turned on, creating yellow
circle(1125, 400, 150);
//stop light green
fill(0, gvalue, 0); //gvalue is 0 when black and 255 when light is on showing green
circle(1125, 575, 150);
}
function keyPressed() {
if(rvalue == 0){
rvalue = 255;
gvalue = 255;
bvalue = 255;
}
else{
rvalue = 0;
gvalue = 0;
bvalue = 0;
}
}
Comments
Post a Comment