Browse Source

Alter all js to use new es6 module syntax

master
parent
commit
9f835820dc
4 changed files with 15 additions and 1 deletions
  1. +3
    -0
      Random.js
  2. +4
    -0
      Star.js
  3. +7
    -0
      Starlight-Renderer.js
  4. +1
    -1
      Vector.js

+ 3
- 0
Random.js View File

@@ -1,3 +1,5 @@
"use strict";

/**
* Bounded random number generator. Has 3 forms:
*
@@ -18,3 +20,4 @@
function random(a,b,c,d)
{d=Math.random();if(typeof a!="number")return d;a=typeof b=="number"?d*(a-b)+b:d*a;a=(typeof b!="number"?b:c)?a:Math.floor(a);return a;}

export default random;

+ 4
- 0
Star.js View File

@@ -1,5 +1,7 @@
"use strict";

import Vector from './Vector';

class Star
{
constructor(inCanvas, inPosition, inSize)
@@ -28,3 +30,5 @@ class Star
context.restore();
}
}

export default Star;

+ 7
- 0
Starlight-Renderer.js View File

@@ -1,5 +1,12 @@
"use strict";

import random from './Random'; // Bounded random number generation
import Vector from './Vector'; // 2D vector class
// Subclasses
import Star from './Star';

// ~~~

class StarlightRenderer
{
constructor(canvas)


+ 1
- 1
Vector.js View File

@@ -215,4 +215,4 @@ class Vector {
}
}
// Make Vector.js Node.js friendly
if (typeof module != "undefined" && module.exports) module.exports = Vector;
export default Vector;

Loading…
Cancel
Save