Skip to content

Instantly share code, notes, and snippets.

@PaulMorel
Last active April 19, 2016 20:35
Show Gist options
  • Save PaulMorel/3db933af744a3f44f506d9751e29b61d to your computer and use it in GitHub Desktop.
Save PaulMorel/3db933af744a3f44f506d9751e29b61d to your computer and use it in GitHub Desktop.
'use strict';
// Block Coordinate System
// Starts from the bottom left. All values are positive. 0,0 is 1 block
//
// Shape order is clockwise starting from the top.
var tetrominoShapes = {
// I Block
0: [
[1,0, 1,1, 1,2, 1,3],
[],
[],
[],
]
}
class Tetromino {
constructor(type) {
if ( ( isNaN(parseFloat(type)) && ! isFinite(type)) || type > 6 ) {
this.randomize();
} else {
this.type = type;
}
}
randomize() {
this.type = Math.floor( Math.random() * 7 );
}
}
var Tetris = class {
constructor() {
this.xyz = 'TETRIS!';
}
}
var currentTetromino = new Tetromino(7);
var nextTetrominoes = [];
for (let i = 0; i < 6; i++) {
nextTetrominoes.push( new Tetromino() );
}
console.log(currentTetromino.type);
console.log(nextTetrominoes);
console.log(Tetris);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment