game-of-death

antagonistic game of life  https://xi.github.io/game-of-death/
git clone https://git.ce9e.org/game-of-death.git

commit
8efa3f23a674b15df0a8906e4fc4988138c7d877
parent
d4dd40c9688844f2792ba60677ad010f3df9f4c9
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2019-10-20 12:05
use es6 modules

Diffstat

M index.html 2 +-
M src/constants.js 20 +++++++++-----------
M src/index.js 6 +++---
M src/logic.js 11 +++--------
M src/template.js 2 +-

5 files changed, 17 insertions, 24 deletions


diff --git a/index.html b/index.html

@@ -9,6 +9,6 @@
    9     9     </head>
   10    10     <body>
   11    11         <script src="node_modules/petit-dom/dist/petit-dom.min.js"></script>
   12    -1         <script src="index.js"></script>
   -1    12         <script type="module" src="src/index.js"></script>
   13    13     </body>
   14    14 </html>

diff --git a/src/constants.js b/src/constants.js

@@ -1,13 +1,11 @@
    1    -1 module.exports = {
    2    -1     EMPTY: 0,
    3    -1     GAIA: -1,
   -1     1 export const EMPTY = 0;
   -1     2 export const GAIA = -1;
    4     3 
    5    -1     alive: [2,3],
    6    -1     born: [3],
   -1     4 export const alive = [2,3];
   -1     5 export const born = [3];
    7     6 
    8    -1     playerCount: 5,
    9    -1     height: 40,
   10    -1     width: 60,
   -1     7 export const playerCount = 5;
   -1     8 export const height = 40;
   -1     9 export const width = 60;
   11    10 
   12    -1     playTimeout: 200,
   13    -1 
   13    -1 
\ No newline at end of file
   -1    11 export const playTimeout = 200
   -1    11 
\ No newline at end of file

diff --git a/src/index.js b/src/index.js

@@ -1,6 +1,6 @@
    1    -1 const template = require('./template.js');
    2    -1 const logic = require('./logic.js');
    3    -1 const constants = require('./constants.js');
   -1     1 import template from './template.js';
   -1     2 import * as logic from './logic.js';
   -1     3 import * as constants from './constants.js';
    4     4 
    5     5 let state, tree;
    6     6 

diff --git a/src/logic.js b/src/logic.js

@@ -1,6 +1,6 @@
    1    -1 const constants = require('./constants.js');
   -1     1 import * as constants from './constants.js';
    2     2 
    3    -1 const setupBoard = function() {
   -1     3 export const setupBoard = function() {
    4     4     const board = [];
    5     5     for (let y = 0; y < constants.height; y++) {
    6     6         board[y] = [];
@@ -11,7 +11,7 @@ const setupBoard = function() {
   11    11     return board;
   12    12 };
   13    13 
   14    -1 const calculateNextGen = function(state) {
   -1    14 export const calculateNextGen = function(state) {
   15    15     const board = state.game.board;
   16    16     const calcBoard = [];
   17    17 
@@ -69,9 +69,4 @@ const getFriendlyNeighbors = function(board, x, y, p){
   69    69         }
   70    70     }
   71    71     return count;
   72    -1 };
   73    -1 
   74    -1 module.exports = {
   75    -1     setupBoard: setupBoard,
   76    -1     calculateNextGen: calculateNextGen,
   77    72 }
   77    72 
\ No newline at end of file

diff --git a/src/template.js b/src/template.js

@@ -42,7 +42,7 @@ const renderMenu = function(state) {
   42    42     ]);
   43    43 };
   44    44 
   45    -1 module.exports = function(state) {
   -1    45 export default function(state) {
   46    46     if (state.game) {
   47    47         return h('div', {}, [
   48    48             renderControls(state),