Skip to content

Instantly share code, notes, and snippets.

@vinskim
Created September 27, 2017 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinskim/5b113083e466d9dec4303dab03c24296 to your computer and use it in GitHub Desktop.
Save vinskim/5b113083e466d9dec4303dab03c24296 to your computer and use it in GitHub Desktop.
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