The project mainly uses the module 1 technique to implement Tetris as the game history legend. The rules of the game are simple. When a line is filled while stacking blocks, the line disappears. The game holds out until the end so that the blocks do not accumulate to the top. The player needs to pass the stage with a particular score.
- DOM methods
:
addEventlistner()
,document.querySelector()
,appendChild()
,createElement
- function method
:
forEach()
,Object.assign()
- ES6 javascript
:
destructure
-
Setting
Tetris's playground, the grid, is formed by HTML elementsul
andli
without using canvas. Theul
andli
nodes can access like an array. For 10 x 20 grid, variablegridRow
,gridColumn
should be declared by each 10 and 20. After making a 2-dimensional list array with nested for loop, the CSS class will take the HTML element to style the grids. -
Shapes
The basic block structure containstype
,direction
,left
,top
. Depending on each index, Tetris blocks can be built up. The variableblocks
has the grid indexes arrays, including rotated shapes. Coloring also -
Moving
To handle blocks by keyboard,eventListener
andkeyCode
are set up with if statement.
- Only using pure HTML, CSS, Javascript, no package.
- Rotating the blocks with the up keypress.
- Stack the blocks.
- Erase the previous block moves.
- Erase the one-line block.
- The blocks don't get out of the playground within the playground.
- Seize the blocks.
- The blocks didn't go out, but there are error messages from undefined blocks.
- Stack the blocks.
- Erase the one-line block.