Skip to content

Instantly share code, notes, and snippets.

View bogoreh's full-sized avatar
🎯
Focusing

bogoreh

🎯
Focusing
View GitHub Profile
//global variable as gravity force
var force = 1;
//Biggest possible PVector that fits in the canvas
var maxDir = PVector.sub (new PVector (0, 0), new PVector (width-1, height-1));
//Magnitude of that vector
var maxMag = maxDir.mag();
//defining the properties of the flower
var G = 1;
//mover function containing properties of the circles
var Mover = function(m, x, y) {
this.mass = m;
this.position = new PVector(x, y);
this.velocity = new PVector(0, 0);
this.acceleration = new PVector(0, 0);
};
var G = 1;
//mover function containing properties of the circles
var Mover = function(m, x, y) {
this.mass = m;
this.position = new PVector(x, y);
this.velocity = new PVector(0, 0);
this.acceleration = new PVector(0, 0);
};
//function containing properties of the attractor
var Attractor = function() {
this.position = new PVector(width/2, height/2);
this.mass = 20;
this.G = 1;
};
Attractor.prototype.calculateAttraction = function(m) {
//direction of the force
//function containing properties of the liquid
var Liquid = function(x, y, w, h, c) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.c = c;
};
//checking if the liquid contains the logs
//declaring properties of the Skateboard
var Skateboard = function(x, m) {
this.mass = m;
this.position = new PVector(x, 0);
this.velocity = new PVector(0, 0);
this.acceleration = new PVector(0, 0);
this.width = this.mass*16;
this.height = this.mass*16*2;
};
//function declaring properties of balls
var Ball = function(m, x, y) {
this.mass = m;
this.position = new PVector(x, y);
this.velocity = new PVector(0, 0);
this.acceleration = new PVector(0, 0);
this.color = color(random(255), random(255), random(255), 127);
};
//applying the forces to change acceleration
//function declaring original properties of the balloon
var Balloon = function() {
this.mass = 1;
this.height = 100;
this.width = 70;
this.position = new PVector(width/2, height-this.height/2-10);
this.velocity = new PVector(0, 0);
this.acceleration = new PVector(0, 0);
};
//Biggest possible PVector that fits in the canvas
var maxDir = PVector.sub (new PVector (0, 0), new PVector (width-1, height-1));
//Magnitude of that vector
var maxMag = maxDir.mag();
//function containing original position, velocity and acceleration
var Mover = function() {
this.position = new PVector(width/2, height/2);
this.velocity = new PVector(0, 0);
//Biggest possible PVector that fits in the canvas
var maxDir = PVector.sub (new PVector (0, 0), new PVector (width-1, height-1));
//Magnitude of that vector
var maxMag = maxDir.mag();
//function containing original position, velocity and acceleration
var Mover = function() {
this.position = new PVector(width/2, height/2);
this.velocity = new PVector(0, 0);