@gati/space-invaders
v1.0.2
Published
A terminal-based Space Invaders game written in TypeScript
Maintainers
Readme
Terminal Space Invaders
A classic Space Invaders game implemented in TypeScript that runs in your terminal!
Features
- 🚀 Classic Space Invaders gameplay
- 🎮 Keyboard controls (WASD, arrow keys, or hjkl)
- 🎯 Multiple enemy types with different point values
- 📊 Score tracking and level progression
- 🎨 Colorful terminal graphics using ANSI colors
- ⏸️ Pause functionality
- 🔄 Restart capability
Installation
- Clone or download this project
- Install dependencies:
npm install
How to Play
Build and run the game:
npm run playOr use the simple launcher:
./play.jsOr build and run separately:
npm run build npm start
Controls
- A or H: Move left
- D or L: Move right
- W, K, or Space: Shoot
- P: Pause/unpause the game
- ESC: Pause the game
- Q: Quit the game
- R: Restart (when game over)
Gameplay
- Destroy all enemies to advance to the next level
- Different enemy types give different points:
- Red diamonds (♦): 30 points
- Yellow spades (♠): 20 points
- Cyan clubs (♣): 10 points
- Enemies move faster as levels progress
- Game ends if enemies reach your position
- You have 3 lives (feature can be extended)
Development
- Build:
npm run build - Watch mode:
npm run dev(rebuilds on file changes) - Start:
npm start(runs the compiled JavaScript)
Technical Details
This game is built with:
- TypeScript for type safety and modern JavaScript features
- Node.js for terminal I/O and process management
- Chalk for colorful terminal output
- Raw terminal input handling for responsive controls
- Object-oriented design with separate classes for rendering, input, and game logic
File Structure
src/
├── index.ts # Main entry point
├── game.ts # Core game engine and logic
├── renderer.ts # Terminal rendering system
├── input.ts # Keyboard input handling
└── types.ts # TypeScript type definitionsEnjoy playing Space Invaders in your terminal! 🚀👾
