Skip to content

idirdev/terminal-games

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archived — Kept for reference. Not part of the current portfolio.

Terminal Games

Node.js TypeScript License Games

A collection of classic terminal-based games built with TypeScript and Node.js. Play Snake, Tetris, Minesweeper, 2048, and Tic-Tac-Toe directly in your terminal with colorful graphics rendered using box-drawing characters and chalk.

Games

# Game Description
1 Snake Navigate the snake to eat food and grow. Avoid walls and your own tail. Speed increases every 5 food eaten.
2 Tetris Stack tetrominoes, clear lines, and chase high scores. Features all 7 pieces (I, O, T, S, Z, L, J), rotation with wall kick, line-clear combos (100/300/500/800), and increasing speed per level.
3 Minesweeper Uncover tiles without hitting mines. Three difficulty levels (Easy 9x9, Medium 16x16, Hard 20x16). Features flood-fill reveal, flagging, and timed scoring.
4 2048 Slide tiles on a 4x4 grid to merge matching numbers. Reach the 2048 tile to win, then keep going for a higher score.
5 Tic-Tac-Toe Challenge an unbeatable AI powered by the minimax algorithm with alpha-beta pruning. Track wins, losses, and draws across rematches.

Controls

Key Action
W / Up Arrow Move up
A / Left Arrow Move left
S / Down Arrow Move down
D / Right Arrow Move right
Space / Enter Confirm / Place / Reveal
F Flag (Minesweeper)
R Rematch (Tic-Tac-Toe)
C Continue after win (2048)
Q / Escape Quit to menu
Ctrl+C Force exit

How to Play

Prerequisites

  • Node.js 18+ and npm
  • A terminal that supports ANSI escape codes and Unicode box-drawing characters

Installation

git clone <repo-url> terminal-games
cd terminal-games
npm install

Run

npm run dev

Or build and start separately:

npm run build
npm start

The game menu will appear in your terminal. Press a number key (1-5) to start a game, or Q to quit.

High Scores

Scores are automatically saved to scores.json in the project root. Each game keeps a leaderboard of the top 10 scores, displayed at the end of each round.

Project Structure

terminal-games/
├── src/
│   ├── index.ts               # Main menu and game launcher
│   ├── games/
│   │   ├── snake.ts           # Snake game (20x20 grid, WASD controls)
│   │   ├── tetris.ts          # Tetris (10x20 board, 7 tetrominoes)
│   │   ├── minesweeper.ts     # Minesweeper (3 difficulties, flood-fill)
│   │   ├── 2048.ts            # 2048 (4x4 grid, slide & merge)
│   │   └── tictactoe.ts       # Tic-Tac-Toe (minimax AI)
│   └── utils/
│       ├── terminal.ts        # Terminal helpers (cursor, colors, input)
│       └── score.ts           # High score persistence
├── package.json
├── tsconfig.json
└── scores.json                # Auto-generated leaderboard data

License

MIT


🇫🇷 Documentation en français

Description

Terminal Games est une collection de jeux classiques jouables directement dans le terminal, développée en Node.js. Elle comprend des jeux comme le Snake, le Pendu et le Morpion, avec une interface textuelle interactive. Idéal pour explorer la programmation de jeux en mode console.

Installation

npm install

Utilisation

npm start   # Lancer le menu principal
npm test    # Lancer les tests

About

Terminal-based games collection (archived)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors