Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Heminger authored and Jeremy Heminger committed Dec 3, 2018
1 parent 3b04ff0 commit 7306d60
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
19 changes: 15 additions & 4 deletions js/gravity.js
@@ -1,22 +1,32 @@
/**
*
*
* */
var Gravity = (function(){

// @var {Boolean}
var haserror = false;

// @var {Boolean}
var boolcollision = false;

// @var {Boolean}
var boolaccretion = false;

/**
* @param {Object}
* @param {Object}
* @returns {Void}
* */
var calc = function(a,b) {


// get the object variables
a = a.get();
b = b.get();


// create a new vector object
b.v = new Vector(b.x,b.y);

// user error check

if(undefined === a.x) {
console.log("ERROR:: Object[a] requires a.x coordinate to be initialized");
haserror = true;
Expand Down Expand Up @@ -46,6 +56,7 @@ var Gravity = (function(){
let v = new Vector(0,0);
let av = new Vector(0,0);
let bv = new Vector(0,0);

b.v.x -= a.x;
b.v.y -= a.y;

Expand Down
17 changes: 17 additions & 0 deletions js/protohacks.js
@@ -1,9 +1,21 @@
// Some hacks to attach DOM Node class functions

/**
* if this node has a specified class
* @param {String}
* @returns {Boolean}
* */
HTMLElement.prototype.hasClass = function(c) {
if (this.classList) {
return this.classList.contains(c);
}
return !!this.className.match(new RegExp('(\\s|^)' + c + '(\\s|$)'));
}
/**
* add a class to a node if it does not yet exist
* @param {String}
* @returns {Void}
* */
HTMLElement.prototype.addClass = function(c) {
if (this.classList) {
this.classList.add(c);
Expand All @@ -13,6 +25,11 @@ HTMLElement.prototype.addClass = function(c) {
}
}
}
/**
* removes a class from the list in a node
* @param {String}
* @returns {Void}
* */
HTMLElement.prototype.removeClass = function(c) {
if (this.classList) {
this.classList.remove(c);
Expand Down
3 changes: 3 additions & 0 deletions js/script.js
Expand Up @@ -25,7 +25,9 @@ var canvas, ctx, _objects = [], isrunnning = true, W, H;


window.onload = function(){
// build a canvas
buildCanvas(function(){
// set the values based on init
document.getElementById("SOLARSIZE").value = SOLARSIZE;
document.getElementById("SOLARMASS").value = SOLARMASS;
document.getElementById("PLANETMASS").value = PLANETMASS;
Expand All @@ -40,6 +42,7 @@ window.onload = function(){
document.getElementById("BOOLCOLLISION").checked = BOOLCOLLISION;
document.getElementById("BOOLACCRETION").checked = BOOLACCRETION;

// run everything
run();
});
}
Expand Down

0 comments on commit 7306d60

Please sign in to comment.