This project is a simple Tetris-like game implemented in TypeScript. It replicates the classic gameplay of Tetris, where players control falling Tetrominoes (shapes composed of four blocks) and aim to create complete horizontal lines on the game board. When a line is completed, it disappears, and the player scores points.
- Control falling Tetrominoes using arrow keys.
- Automatic downward movement of Tetrominoes with a configurable interval.
- Rotation of Tetrominoes.
- Clearing full rows when they are completed.
- Basic game loop for continuous gameplay.
- Rendering using HTML canvas.
-
Clone the repository
-
Install dependencies: npm install
-
Build the project: npm run build
-
Open
index.html
in a web browser to play the game.
-
Controls:
-
Arrow keys: Move Tetrominoes left, right, up, or down, and rotate them.
-
Space
: Hard drop (instantly move Tetromino down to the lowest possible position). -
Scoring:
-
Clear one line: 10 points.
-
Clear two lines simultaneously (Tetris): 20 points.
-
Clearing multiple lines at once increases the score multiplier.
-
Game Over:
-
The game ends when a new Tetromino cannot be placed on the board.
-
src/
: Contains TypeScript source code. -
tetris/index.ts
: Defines theGame
class responsible for game logic. -
Tetromino.ts
: Defines theTetromino
class representing Tetromino shapes. -
style.css
: Contains styles for the game interface. -
index.html
: HTML file for rendering the game.
- TypeScript
- HTML Canvas