Instantly share code, notes, and snippets.

Embed
What would you like to do?
3Week - Winter Wonderland
let x = 0;
let y = 0;
let snowx, snowy;
let snowstate = false;
let textcolor = 220;
let snowc ;
let size = 10;
let r = 255;
g = 255;
b = 255;
function setup() {
createCanvas(600, 400);
background(230);
snowx = width / 3 * 2.8;
snowy = height / 1 * 0.85;
}
function draw() {
////// caption
fill(230, 0, 0);
textSize(15);
text("Winter Wonderland", snowx-110, snowy+30);
///// mouse over
if(mouseX>snowx-25 && mouseX<snowx+25 && mouseY>snowy-50 && mouseY<snowy+50) {
snowc = 255 ;
} else {
snowc = 180;
}
///// snow button
fill(0, 153, 0);
noStroke()
ellipse(snowx, snowy, 20, 20);
///// snow
if (snowstate) {
if (random(1) > 0.5) {
fill(217, 217, 217);
} else {
fill(217);
text("*", x, y);
}
y += 20;
if (x > width) {
background(0);
x = 0;
y = 0;
}
if (y > height) {
x += 20;
y = 0;
}
}
}
///// clicking the snow button
function mousePressed() {
if (mouseX>snowx-25 && mouseX<snowx+25 && mouseY>snowy-50 && mouseY<snowy+50) {
background(30);
fill(150);
snowstate = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment