From c0c81275fadf72ecfa3d5b3179de79a1eba2916b Mon Sep 17 00:00:00 2001 From: jim-clark Date: Fri, 26 Jul 2019 11:02:30 -0700 Subject: [PATCH] Style circles and initialize state --- css/main.css | 24 ++++++++++++++++++++++++ js/main.js | 24 +++++++++++++++++++++--- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/css/main.css b/css/main.css index e69de29..3811df1 100644 --- a/css/main.css +++ b/css/main.css @@ -0,0 +1,24 @@ +*, *::before, *::after { + box-sizing: border-box; +} + +body { + height: 100vh; + margin: 0; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} + +section { + display: grid; + grid-template-columns: repeat(7, 10vmin); + grid-template-rows: repeat(6, 10vmin); + grid-gap: 1vmin; +} + +section div { + border-radius: 50%; + border: 1px solid grey; +} \ No newline at end of file diff --git a/js/main.js b/js/main.js index bd1bdc5..52db426 100644 --- a/js/main.js +++ b/js/main.js @@ -1,8 +1,12 @@ /*----- constants -----*/ - +const COLORS = { + '0': 'white', + '1': 'purple', + '-1': 'lime' +}; /*----- app's state (variables) -----*/ - +let board, turn, winner; /*----- cached element references -----*/ @@ -10,4 +14,18 @@ /*----- event listeners -----*/ -/*----- functions -----*/ \ No newline at end of file +/*----- functions -----*/ + +function init() { + board = [ + [0, 0, 0, 0, 0, 0], // column 1 (index 0) + [0, 0, 0, 0, 0, 0], // column 2 (index 1) + [0, 0, 0, 0, 0, 0], // column 3 (index 2) + [0, 0, 0, 0, 0, 0], // column 4 (index 3) + [0, 0, 0, 0, 0, 0], // column 5 (index 4) + [0, 0, 0, 0, 0, 0], // column 6 (index 5) + [0, 0, 0, 0, 0, 0], // column 7 (index 6) + ]; + turn = 1; + winner = null; // 1, -1, null (no winner), 'T' (tie) +} \ No newline at end of file