A side-by-side comparison of a classic Space Invaders game implemented in two different approaches:
- Legacy Edition: Vanilla JavaScript + jQuery + Canvas API
- Modern Edition: TypeScript + Vite + Modern ES6+ Modules
- 🕹️ Classic Space Invaders gameplay
- 🎮 Both implementations running simultaneously
- 📦 Self-contained build systems for each version
- 🚀 Production-ready static builds
- 🔄 Independent development workflows
npm run install:allThis installs dependencies for both the legacy and modern editions.
npm run buildOr use the build script directly:
./build.shnpm run serveThen open your browser to:
http://localhost:8000/index.html
You'll see both games running side-by-side! 🎉
spaceinvadersdemo/
├── index.html # Landing page showing both games
├── build.sh # Master build script
├── package.json # Root scripts and commands
│
├── legacy/ # Legacy Edition (Vanilla JS)
│ ├── main.html # Game entry point
│ ├── js/ # Game logic files
│ │ ├── sprite.js
│ │ ├── game-logic.js
│ │ ├── game-menu.js
│ │ └── level.js
│ ├── css/ # Styles
│ ├── images/ # Sprite sheets
│ ├── media/ # Sound effects
│ ├── build.js # Legacy build script
│ └── dist/ # Built output (after build)
│
└── modern/ # Modern Edition (TypeScript)
├── index.html # Game entry point
├── src/ # TypeScript source files
│ ├── main.ts
│ └── modules/
│ ├── game.ts
│ ├── entities.ts
│ ├── board.ts
│ └── ...
├── public/ # Static assets
├── package.json # Modern dependencies
└── dist/ # Built output (after build)
- Arrow Keys - Move left/right
- Spacebar - Fire missiles
- + / - Keys - Adjust speed (Legacy only, debug feature)
From the project root:
# Installation
npm run install:all # Install all dependencies
# Building
npm run build # Build both games
npm run build:legacy # Build legacy only
npm run build:modern # Build modern only
npm run clean # Remove all build outputs
# Development
npm run dev:legacy # Develop legacy (port 8080)
npm run dev:modern # Develop modern (Vite dev server)
# Serving
npm run serve # Serve the landing page (port 8000)cd legacy
# Edit files in js/, css/, images/, media/
# Test by opening main.html directly or:
python3 -m http.server 8080
# Rebuild when ready:
npm run buildcd modern
# Edit files in src/
npm run dev # Hot module reloading!
# Build when ready:
npm run build- Make changes to either codebase
- Run
npm run buildfrom root - Run
npm run servefrom root - Open
http://localhost:8000/index.html
To deploy to static hosting (Netlify, Vercel, GitHub Pages, etc.):
-
Run the build:
npm run build
-
Upload the entire project directory (including
legacy/dist/andmodern/dist/) -
Set
index.htmlas the entry point
The landing page will automatically serve both games from their dist folders.
- Classic JavaScript patterns
- jQuery for DOM manipulation
- Single file architecture
- Global state management
- Immediate execution
- TypeScript with type safety
- Modular ES6+ architecture
- Vite for fast builds
- Class-based entity system
- Strict mode compilation
Feel free to explore both implementations and see how the same game logic can be expressed in different paradigms!
MIT
Enjoy the comparison! 🚀👾