Start writing the game

This commit is contained in:
Aaron Fischer 2015-08-24 16:28:52 +02:00
parent 115859a301
commit 46f2640bab
3 changed files with 53 additions and 6 deletions

View File

@ -1,7 +1,8 @@
default: compile
compile:
traceur --script src/*.js --out out/js13kgames-2015.js
mkdir -p out
babel src/*.js -o out/js13kgames-2015.js
uglifyjs --compress --mangle -- out/js13kgames-2015.js > out/js13kgames-2015.min.js
rm out/js13kgames-2015.js
cp -f src/*.{html,css} out/

View File

@ -2,12 +2,18 @@
<head>
<meta charset="utf-8">
<title>js13kGames 2015 -- Aaron Fischer</title>
<script src="js13kgames-2015.js"></script>
<script src="js13kgames-2015.min.js"></script>
</head>
<body>
<nav>
<ul>
<li>Dust: <strong id="res-dust">0</strong></li>
<li>Time on this ateroid: <strong id="time">0 hours</strong></li>
</ul>
</nav>
<script>
bootstrap();
</script>
<button id="btn-mine">Mine on this asteroid</button>
<script>bootstrap();</script>
</body>
</html>

View File

@ -1,3 +1,43 @@
class Engine {
constructor() {
this.ticks = 0;
this.resources = {
dust: 0
}
}
tick() {
this.ticks++;
}
update() {
document.querySelector('#time').innerHTML = this.ticks + ' hours';
document.querySelector('#res-dust').innerHTML = this.resources.dust;
}
}
class Player {
constructor(engine) {
this.engine = engine;
}
mine() {
console.log('mine');
this.engine.resources.dust++;
}
}
var engine = new Engine();
var player = new Player(engine);
var bootstrap = function() {
console.log("Hi du");
setInterval(() => {
engine.tick();
engine.update();
}, 1000);
document.querySelector('#btn-mine').onclick = () => {
player.mine();
engine.update();
};
};