Add crystals and and try to use the export/import mechanism from ES6

This commit is contained in:
Aaron Fischer 2015-08-24 16:42:43 +02:00
parent 46f2640bab
commit 6293ce1986
3 changed files with 15 additions and 1 deletions

3
src/helpers.js Normal file
View File

@ -0,0 +1,3 @@
export function random_number(min, max) {
Math.floor((Math.random() * max) + min);
};

View File

@ -8,6 +8,7 @@
<nav>
<ul>
<li>Dust: <strong id="res-dust">0</strong></li>
<li>Crystals: <strong id="res-crystals">0</strong></li>
<li>Time on this ateroid: <strong id="time">0 hours</strong></li>
</ul>
</nav>

View File

@ -1,8 +1,11 @@
import random_number from './helpers';
class Engine {
constructor() {
this.ticks = 0;
this.resources = {
dust: 0
dust: 0,
crystals: 0
}
}
@ -27,8 +30,15 @@ class Player {
}
}
class Asteroid {
mine_resource() {
console.log(random_number(2, 10));
}
}
var engine = new Engine();
var player = new Player(engine);
var current_asteroid = new Asteroid();
var bootstrap = function() {
setInterval(() => {