Skip to content

Commit

Permalink
Create static empty board
Browse files Browse the repository at this point in the history
  • Loading branch information
zangston committed Dec 22, 2023
1 parent 53e97a2 commit 09a6275
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 3 deletions.
65 changes: 65 additions & 0 deletions game/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Game board represented as an array of strings, one string per line
// Example board:
/*
<! . . . . . . . . . .!> SCORE
<! . . . . . . . . . .!> 1,000,000
<! . . . . . . . . . .!>
<! . . . . . . . . . .!> LEFT/RIGHT: Move piece
<! . . . . . . . . . .!> X: Rotate clockwise
<! . . . . . . . . . .!> Z: Rotate counterclockwise
NEXT <! . . . . . . . . . .!> Down: Soft drop
[][][][] <! . . . . . . . . . .!> Space: Hard drop
<! . . . . . . . . . .!> Shift: Hold piece
<! . . . . . . . . . .!>
<! . . . . . . . . . .!>
<! . . . . . . . . . .!>
HOLD <! . . . . . . . . . .!>
[] <! . . . . . . . . . .!>
[][][] <! . . . . . . . . . .!>
<! . . . . . . . . . .!>
<! . . . . . . . . . .!>
<! . . . . . . . . . .!>
<! . . . . . . . . . .!>
<! . . . . . . . . . .!>
<! . . . . . . . . . .!>
\/\/\/\/\/\/\/\/\/\/
*/
var board = [];
board[0] = "\n\r";
board[1] = " <! . . . . . . . . . .!> SCORE\n\r";
board[2] = " <! . . . . . . . . . .!> \n\r";
board[3] = " <! . . . . . . . . . .!>\n\r";
board[4] = " <! . . . . . . . . . .!> LEFT/RIGHT: Move piece\n\r";
board[5] = " <! . . . . . . . . . .!> X: Rotate clockwise\n\r";
board[6] = " <! . . . . . . . . . .!> Z: Rotate counterclockwise\n\r";
board[7] = " NEXT <! . . . . . . . . . .!> Down: Soft drop\n\r";
board[8] = " <! . . . . . . . . . .!> Space: Hard drop\n\r";
board[9] = " <! . . . . . . . . . .!> Shift: Hold piece\n\r";
board[10] = " <! . . . . . . . . . .!>\n\r";
board[11] = " <! . . . . . . . . . .!>\n\r";
board[12] = " <! . . . . . . . . . .!>\n\r";
board[13] = " HOLD <! . . . . . . . . . .!>\n\r";
board[14] = " <! . . . . . . . . . .!>\n\r";
board[15] = " <! . . . . . . . . . .!>\n\r";
board[16] = " <! . . . . . . . . . .!>\n\r";
board[17] = " <! . . . . . . . . . .!>\n\r";
board[18] = " <! . . . . . . . . . .!>\n\r";
board[19] = " <! . . . . . . . . . .!>\n\r";
board[20] = " <! . . . . . . . . . .!>\n\r";
board[21] = " <! . . . . . . . . . .!>\n\r";
board[22] = " \\/\\/\\/\\/\\/\\/\\/\\/\\/\\/";

function main(xterm) {
updateScreen(xterm, board);
}

/**
*
* @param {*} xterm
* @param {*} board
*/
function updateScreen(xterm, board) {
for (let i = 0; i < board.length; i++) {
xterm.write(board[i]);
}
}
11 changes: 8 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<style>

body {
margin: 50;
margin-top: 0.5%;
margin-left: 1%
}

#terminal {
width: 325px;
width: 675px;
margin: auto;
}
</style>
Expand All @@ -18,6 +19,8 @@
href="https://unpkg.com/xterm/css/xterm.css"
/>
<script src="https://unpkg.com/xterm/lib/xterm.js"></script>

<script src="./game/main.js"></script>
</head>

<body>
Expand All @@ -27,8 +30,10 @@ <h1>xtermtris</h1>
<script>
var xterm = new Terminal();
xterm.open(document.getElementById('terminal'));
xterm.resize(34, 26);
xterm.resize(70, 24);
xterm.write("\x1B[0;32m"); // Note: colors dictated by ANSI scheme: https://bixense.com/clicolors/

main(xterm);
</script>
</body>
</html>

0 comments on commit 09a6275

Please sign in to comment.