From 07b3dd3b5759bc25e9e867345d2688bbc2db3178 Mon Sep 17 00:00:00 2001
From: 12913378 <harry.buttenshaw@student.uts.edu.au>
Date: Sun, 27 Oct 2019 19:16:16 +1100
Subject: [PATCH] Upload New File

---
 Code/Snowflake.js | 77 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Code/Snowflake.js

diff --git a/Code/Snowflake.js b/Code/Snowflake.js
new file mode 100644
index 0000000..766a547
--- /dev/null
+++ b/Code/Snowflake.js
@@ -0,0 +1,77 @@
+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);
+//
+
+}
-- 
GitLab