Skip to content
Snippets Groups Projects
Commit 07b3dd3b authored by 12913378's avatar 12913378
Browse files

Upload New File

parent 7e5d3d8f
Branches
No related merge requests found
function getRandomSize(){
let r = pow(random(0, 1), 5);
return constrain(r * 36, 2, 36);
//let r = randomGaussian() * 2;
//return constrain(abs(r * r), 2 , 36);
//while (true){
//let r1 = random(1);
//let r2 = random(1);
//if (r2 > r1) {
//return r1 * 36;
//}
//}
}
class Snowflake {
constructor() {
let x = random(width);
let y = random(-100, -10);
this.pos = createVector(x, y);
this.vel = createVector(0, 0);
this.acc = createVector();
this.r = getRandomSize();
}
applyForce(force){
//Parallax Effect hack
let f = force.copy();
f.mult(this.r);
//let f = force.copy();
//f.div(this.mass);
this.acc.add(f);
}
randomize(){
let x = random(width);
let y = random(-100, -10);
this.pos = createVector(x, y);
this.vel = createVector(0, 0);
this.acc = createVector();
this.r = getRandomSize();
}
update() {
this.vel.add(this.acc);
this.vel.limit(this.r * 0.2);
if (this.vel.mag()<1) {
this.vel.normalize();
}
this.pos.add(this.vel);
this.acc.mult(1);
if (this.pos.y > height + this.r) {
this.randomize();
}
}
//this is a funtion that
render() {
stroke(255);
image(snowImage,this.pos.x,this.pos.y,this.r,this.r);
strokeWeight(this.r);
}
//offScreen(){
// return(this.pos.y > height + this.i);
//
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment