paxif.blogg.se

Tetris math is fun
Tetris math is fun







Var board = document.getElementsB圜lassName('tetris-board') The board itself will be comprised of div elements created dynamically in JavaScript. Based on the actual game specs for Tetris, the number of horizontal running boxes is 10 and we can take some liberty with the height. Making the Tetris boardįirst off, let's make the game board where the game will take place. currentShape => the current shape in play - height => height of the game board - width => width of the game board - state => used to monitor the current state of the gameplay - colors => available colors to use when rendering shapes - move => tracks the number of moves the user has made so far - occupiedBlocks => array containing a list of all current blocks on the board that are filled - direction => 'up', 'down', 'left', 'right' string used to track where to draw the falling block next - points => running tally of total points Step 2. shapes => a collection of the possible shapes that can be drawn. Here is a breakdown of each of the variables and what they are designed to do. Var state = 1 // 1 running - 0 paused - 2 game over

tetris math is fun

Here are all the variables that will be defined in the making of this game. This isn't 1950, so memory is more than plentiful.









Tetris math is fun