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
248a5f6ebaa58905954ae9098f6813887ecf1c11
parent
b2ffceb75a7627629451bc41d2bdaa85e43d00f7
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2019-10-31 06:35
highlight limit

Diffstat

M src/template.js 13 ++++++++++---
M style.css 4 ++++

2 files changed, 14 insertions, 3 deletions


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

@@ -2,16 +2,23 @@ import scenarios from './scenarios.js';
    2     2 
    3     3 const h = petitDom.h;
    4     4 
   -1     5 const getSpaceClass = function(state, y, x) {
   -1     6     if (
   -1     7         (state.game.limitBuildSpace) &&
   -1     8         (x < state.game.limitBuildSpace.x1 || x > state.game.limitBuildSpace.x2 || y < state.game.limitBuildSpace.y1 || y > state.game.limitBuildSpace.y2)
   -1     9     ) return 'limit-outside';
   -1    10 };
   -1    11 
    5    12 const renderBoard = function(state) {
    6    13     return h(
    7    14         'div',
    8    15         {'class': 'board'},
    9    -1         state.game.board.map(row => h(
   -1    16         state.game.board.map((row, y) => h(
   10    17             'div',
   11    18             {'class': 'board-row'},
   12    -1             row.map(player => h(
   -1    19             row.map((player, x) => h(
   13    20                 'div',
   14    -1                 {'class': `board-cell bg-${player}`}
   -1    21                 {'class': `board-cell bg-${player} ${getSpaceClass(state, y, x)}`}
   15    22             ))
   16    23         ))
   17    24     );

diff --git a/style.css b/style.css

@@ -122,3 +122,7 @@ input[type=range]:focus::-webkit-slider-thumb {
  122   122 .bg-2 {--cell-color: var(--player2); z-index: 1}
  123   123 .bg-3 {--cell-color: var(--player3); z-index: 1}
  124   124 .bg-4 {--cell-color: var(--player4); z-index: 1}
   -1   125 
   -1   126 .bg-0.limit-outside {
   -1   127     opacity: 0.7;
   -1   128 }