xxxxxxxxxx
58
let noiseScale=0.02;
let slider
let button
var snow_length=3
var r=255
var g=255
var b=255
var snow=[]
var count=25
function preload(){
Bimg=loadImage('background.png')
}
function setup(){
createCanvas(400,400)
slider=createSlider(0,height-100,200)
button=createButton('New Landscape')
button.mousePressed(reload)
for (i = 0; i < count; i++) {
snow[i]= new Snow(random(width),random(-15),random(5,15))
}
mheight=slider.value()
for (i=0;i<50;i++) {
circle(random(width),random(mheight,0),5)
}
}
function draw() {
snow_length+=0.005
background(Bimg);
for (i = 0; i < snow.length; i++) {
snow[i].fall()
snow[i].show()
snow[i].refresh()
}
mheight=slider.value()
for (let x=0; x < width; x++) {
let noiseVal = noise((x)*noiseScale,noiseScale);
let y=mheight+noiseVal*80
stroke(165,165,165);
rect(x, mheight+noiseVal*80, 1, height);
fill(r,g,b)
noStroke()
rect(x,y-snow_length,1,snow_length)
}
if (snow_length>=15){
snow_length=3
}
}
function reload(){
location.reload()
}