From 46f2640bab121e7c3d7a5a3cc1b2e920ba75f260 Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Mon, 24 Aug 2015 16:28:52 +0200 Subject: [PATCH] Start writing the game --- Makefile | 3 ++- src/index.html | 14 ++++++++++---- src/main.js | 42 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 032c9f9..bed1eea 100644 --- a/Makefile +++ b/Makefile @@ -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/ diff --git a/src/index.html b/src/index.html index 6f6b9bd..8e03703 100644 --- a/src/index.html +++ b/src/index.html @@ -2,12 +2,18 @@ js13kGames 2015 -- Aaron Fischer - + + - + + + diff --git a/src/main.js b/src/main.js index 0a5e075..bd9d65a 100644 --- a/src/main.js +++ b/src/main.js @@ -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(); + }; };