Add crystals and and try to use the export/import mechanism from ES6
This commit is contained in:
parent
46f2640bab
commit
6293ce1986
3 changed files with 15 additions and 1 deletions
3
src/helpers.js
Normal file
3
src/helpers.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export function random_number(min, max) {
|
||||||
|
Math.floor((Math.random() * max) + min);
|
||||||
|
};
|
|
@ -8,6 +8,7 @@
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Dust: <strong id="res-dust">0</strong></li>
|
<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>
|
<li>Time on this ateroid: <strong id="time">0 hours</strong></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
12
src/main.js
12
src/main.js
|
@ -1,8 +1,11 @@
|
||||||
|
import random_number from './helpers';
|
||||||
|
|
||||||
class Engine {
|
class Engine {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.ticks = 0;
|
this.ticks = 0;
|
||||||
this.resources = {
|
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 engine = new Engine();
|
||||||
var player = new Player(engine);
|
var player = new Player(engine);
|
||||||
|
var current_asteroid = new Asteroid();
|
||||||
|
|
||||||
var bootstrap = function() {
|
var bootstrap = function() {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
|
Loading…
Reference in a new issue