Skip to content

Instantly share code, notes, and snippets.

@renatocassino
Created August 6, 2018 12:39
Show Gist options
  • Save renatocassino/476c6a1c3740fba4702ba92143433d05 to your computer and use it in GitHub Desktop.
Save renatocassino/476c6a1c3740fba4702ba92143433d05 to your computer and use it in GitHub Desktop.
2048-creating-board.js
const board = [
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
];
// Important, when you see this matix in code,
// you are seeing the board rotated 90 deg to left,
// because the first value is column and the second value is the line
// board[column, line]
// Ex:
const board = [[2, 2, 2, 2], [0, 4, 16, 16], [8, 8, 0, 32], [0, 0, 0, 64]];
// In game you will see this
/*-------------------------
2 | 0 | 8 | 0
2 | 4 | 8 | 0
2 | 16 | 0 | 0
2 | 16 | 32 | 64
-------------------------*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment