Skip to content

engelde/tetris-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Tetris CLI

A CLI recreation of Tetris โ€” right in your terminal. ๐ŸŽฎ

npm version license node

Tetris CLI gameplay demo running in a terminal

"The classic puzzle game, rebuilt for the terminal."

๐Ÿš€ Quick Start

npx @engelde/tetris-cli

One command. No install. Just play.

Want it installed? Run npm install -g @engelde/tetris-cli then just type tetris.

๐Ÿ•น๏ธ What Is This?

A terminal recreation of Tetris โ€” the puzzle game that defined a genre. Seven pieces, one board, infinite challenge. Built with TypeScript, React, and Ink for smooth 60 FPS terminal rendering.

โœจ Features

  • ๐Ÿƒ Marathon โ€” Classic score chase with increasing speed
  • ๐Ÿค– vs CPU โ€” Battle an AI opponent on Easy, Normal, or Hard
  • ๐Ÿ‘ฅ 2-Player โ€” Same-keyboard duel with garbage attacks
  • ๐ŸŽฒ 7-Bag Randomizer โ€” Fair piece distribution every game
  • ๐Ÿ”„ SRS Rotation โ€” Full wall kicks and spin detection
  • ๐Ÿ“ฆ Hold Piece โ€” Swap and strategize
  • ๐Ÿ‘ป Ghost Piece โ€” See exactly where you'll land
  • ๐Ÿ”ฅ Combos & Back-to-Back โ€” Advanced scoring for pros
  • ๐Ÿ—‘๏ธ Garbage System โ€” Send lines to your opponent
  • ๐Ÿ† Local High Scores โ€” Persisted in ~/.tetris-cli-scores.json
  • ๐Ÿ”” Sound Effects โ€” Native chiptune-style game cues (disable with --no-sound)

๐ŸŽฎ Controls

Player 1

Action Keys
Move left A / Left Arrow
Move right D / Right Arrow
Soft drop S / Down Arrow
Hard drop W / Up Arrow
Rotate clockwise K / Z / Space
Rotate counter-clockwise J / X
Hold H / C
Pause P / Escape
Quit Q / Ctrl+C

Player 2

Action Keys
Move left Left Arrow
Move right Right Arrow
Soft drop Down Arrow
Hard drop Up Arrow / Space
Rotate clockwise , / .
Rotate counter-clockwise / / >
Hold ; / L

โš™๏ธ Options

Flag Description Default
--mode <mode> marathon, cpu, or 2p Interactive menu
--difficulty <level> easy, normal, or hard normal
--no-sound Disable sound effects Sound enabled
--help, -h Show help โ€”
--version, -v Show version โ€”
# Examples
npx @engelde/tetris-cli --mode marathon --difficulty easy --no-sound
npx @engelde/tetris-cli --mode cpu --difficulty hard
npx @engelde/tetris-cli --mode 2p

๐Ÿ’ก Pro Tips

๐ŸŽฏ Master the hold โ€” Save an I-piece for the perfect Tetris setup.

๐Ÿ”„ Learn SRS wall kicks โ€” A well-timed rotation can save a piece from a tight spot.

โšก Combos add up โ€” Clearing lines back-to-back sends massive garbage in versus modes.

๐Ÿ“ Watch the ghost โ€” The ghost piece shows your landing spot. Use it to plan ahead.

๐Ÿ› ๏ธ Development

git clone https://github.com/engelde/tetris-cli.git
cd tetris-cli
npm install
Command Description
npm start Run the game
npm test Run tests
npm run build Compile TypeScript
npm run lint Lint with Biome
npm run format Format with Biome

Husky runs linting + tests on pre-commit and enforces Conventional Commits. CI runs on Node 22 / 24. npm publishing is triggered from a published GitHub Release using NPM_TOKEN and provenance.

๐Ÿ“œ Credits

Inspired by the original Tetris created by Alexey Pajitnov in 1984. This is an independent, open-source recreation with no affiliation with The Tetris Company.

๐Ÿ“„ License

MIT

About

A CLI recreation of Tetris โ€” right in your terminal. ๐ŸŽฎ

Resources

License

Stars

Watchers

Forks

Contributors