@@ -44,11 +44,15 @@ function testJestConnection() {
44
44
const playMatrixView = document . querySelector ( '.play-matrix' )
45
45
const playerScoreView = document . querySelector ( '.info .score-span' )
46
46
const globalPlayButton = document . querySelector ( '.play-button' )
47
+ const pageMain = document . querySelector ( 'main' )
48
+ const playerCoreHTML = '<div class="info"><p>Score: <span class="score-span">000</span></p><ul class="controls"><p>Controls:</p></ul></div><div class="play-decorator"><div class="play-matrix"></div></div>'
47
49
// **************************************************************************
48
50
// Variables
49
51
50
52
const isDebugMode = false
51
53
54
+ const players = [ ]
55
+
52
56
const playMatrixHeight = 20
53
57
const playMatrixWidth = 16
54
58
let playMatrix = new Array
@@ -238,6 +242,33 @@ const playerInputScheme = {
238
242
239
243
// **************************************************************************
240
244
// Build play window
245
+
246
+ class TetrisGame {
247
+ constructor ( playerNumber = 1 , displayParent = pageMain ) {
248
+ this . playerNumber = playerNumber
249
+ this . playerName = 'player' + playerNumber
250
+ this . displayParent = displayParent
251
+ this . coreHTML = playerCoreHTML
252
+
253
+ this . initPlayspace ( )
254
+ }
255
+
256
+ initPlayspace ( ) {
257
+ const newPlayerSection = document . createElement ( 'section' )
258
+ newPlayerSection . classList . add ( this . playerName )
259
+ newPlayerSection . innerHTML = this . coreHTML
260
+
261
+ this . displayParent . appendChild ( newPlayerSection )
262
+
263
+ this . playerSection = newPlayerSection
264
+ }
265
+ }
266
+
267
+ players . push ( new TetrisGame )
268
+
269
+
270
+
271
+
241
272
const tetrominoSpawnYX = [ tetrominoSpawnXY [ 1 ] , tetrominoSpawnXY [ 0 ] ]
242
273
243
274
function buildNewPlayMatrix ( height , width ) {
0 commit comments