Skip to content

shlomiNugarker/tetris-vannila-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tetris-Like Game

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.

Features

  • 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.

Setup

  1. Clone the repository

  2. Install dependencies: npm install

  3. Build the project: npm run build

  4. Open index.html in a web browser to play the game.

Gameplay

  • 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.

Files Structure

  • src/: Contains TypeScript source code.

  • tetris/index.ts: Defines the Game class responsible for game logic.

  • Tetromino.ts: Defines the Tetromino class representing Tetromino shapes.

  • style.css: Contains styles for the game interface.

  • index.html: HTML file for rendering the game.

Technologies Used

  • TypeScript
  • HTML Canvas