diff --git a/src/automaton.js b/src/automaton.js new file mode 100644 index 0000000..62d0426 --- /dev/null +++ b/src/automaton.js @@ -0,0 +1,12 @@ +function Automaton(messaging, screen, session) { + var startMenu = ['New Game', 'Settings']; + if(session.hasSavedGame()) { + startMenu.unshift('Continue'); + } + screen.menu(startMenu); + messaging.addEventListener(['Init'], function(game) { + console.log(game); + }); + //messaging.send({tag: 'NewGame'}); + +} diff --git a/src/dom.js b/src/dom.js new file mode 100644 index 0000000..4dbad9b --- /dev/null +++ b/src/dom.js @@ -0,0 +1,36 @@ +function Dom() { + return { + clear: clear, + make: make + } + + function clear(elem) { + while(elem.firstChild) { + elem.removeChild(elem.firstChild); + } + } + + function make(tag, properties, children) { + var e = document.createElement(tag); + properties = properties || {}; + children = children || []; + for(key in properties) { + var value = properties[key]; + switch(key) { + case "class": + e.className = Array.isArray(value) ? value.join(' ') : value; + break;; + case "onClick": + e.addEventListener("click", value); + break;; + default: + e[key] = value; + } + } + for(var i = 0; i < children.length; i++) { + e.appendChild(children[i]); + } + return e; + } + +} diff --git a/src/index.html b/src/index.html index eb78202..6ac2f1f 100644 --- a/src/index.html +++ b/src/index.html @@ -3,9 +3,16 @@