A fast-paced typing-shooter game built with vanilla JavaScript and HTML5 Canvas. Destroy enemy ships by typing words correctly before they reach the bottom.
- Overview
- Features
- Tech Stack
- Getting Started
- Project Structure
- Architecture
- API Reference
- Configuration
- Development
- Performance
- Browser Compatibility
- Deployment
- Contributing
- License
TypeBlaster is a browser-based typing game that combines word recognition with arcade-style gameplay. The game uses HTML5 Canvas for rendering, implements a game loop with requestAnimationFrame, and stores high scores using the Web Storage API.
- Typing System: Real-time word matching with visual feedback
- Wave Progression: Dynamic difficulty scaling based on score
- Enemy AI: Spawn rate and speed increase with each wave
- State Management: Game state machine (start → playing → gameover)
- Particle System: Canvas-based explosion and particle effects
- ✅ Dynamic difficulty scaling with wave progression
- ✅ Word complexity increases with each wave
- ✅ Visual feedback for typed letters (blue highlighting)
- ✅ Particle effects and explosion animations
- ✅ Score system with wave-based multipliers
- ✅ Local high score persistence (localStorage)
- ✅ Zero dependencies - pure vanilla JavaScript
- ✅ Responsive canvas rendering
- ✅ 60 FPS game loop using
requestAnimationFrame - ✅ Event-driven architecture
- ✅ Modular code structure
- ✅ Cross-browser compatibility
| Technology | Purpose |
|---|---|
| HTML5 | Semantic markup and canvas element |
| CSS3 | Styling, animations, and responsive design |
| JavaScript (ES6+) | Game logic, state management, and rendering |
| Canvas API | 2D graphics rendering |
| Web Storage API | High score persistence |
| requestAnimationFrame | Smooth 60 FPS game loop |
- Modern web browser (Chrome, Firefox, Safari, Edge)
- No build tools or package managers required
# Clone the repository
git clone https://github.com/your-username/TypeBlaster.git
# Navigate to project directory
cd TypeBlaster
# Open in browser
# Option 1: Use a local server (recommended)
python -m http.server 8000
# Then visit http://localhost:8000
# Option 2: Open directly
open index.html # macOS
start index.html # Windows
xdg-open index.html # Linux- Open
index.htmlin your browser - Click "Start Game"
- Type words displayed on enemy ships
- Survive as long as possible!
TypeBlaster/
├── assets
│ └──bgTheme
├── index.html # Main HTML structure and game container
├── style.css # Game styles, animations, and responsive design
├── main.js # Core game logic, rendering, and state management
├── words.js # Word lists organized by difficulty level
├── AboutDev.html # Developer information page
├── favicon_io/ # Favicon assets
│ ├── favicon.ico
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ └── ...
└── README.md # Project documentation
States: 'start' → 'playing' → 'gameover' → 'start'- Canvas context and dimensions
- Game parameters (speed, spawn rate, difficulty)
- Current game state and score tracking
- Player: Static position at bottom of canvas
- Enemies: Array of enemy objects with word targets
- Explosions: Particle effects for destroyed enemies
- Particles: Visual effects system
function gameLoop() {
update(); // Update game state
render(); // Render to canvas
requestAnimationFrame(gameLoop);
}- Keyboard event listeners for typing
- Active enemy selection (closest to bottom)
- Text matching algorithm with visual feedback
- Clear canvas
- Draw background (stars)
- Draw player
- Draw enemies with words
- Draw particles/explosions
- Draw UI (score, lives, wave)
- Request next frame
Initializes the game, sets up canvas, event listeners, and initial state.
Resets game state and transitions from 'start' to 'playing'.
Main game update loop. Handles:
- Enemy spawning
- Enemy movement
- Collision detection
- Wave progression
- Game over conditions
Renders all game objects to the canvas in the correct order.
Processes keyboard input for typing system:
- Letter keys: Add to typed text
- Backspace: Remove last character
- Enter: Submit word (if implemented)
const CONFIG = {
canvas: null, // Canvas element
ctx: null, // 2D rendering context
width: 800, // Canvas width
height: 600, // Canvas height
enemyBaseSpeed: 0.5, // Base enemy speed (pixels/frame)
enemySpeedMultiplier: 1.0, // Speed multiplier per wave
spawnRate: 2000, // Milliseconds between spawns
maxEnemies: 5, // Maximum enemies on screen
lives: 3, // Starting lives
score: 0, // Current score
wave: 1, // Current wave number
gameState: 'start', // Current game state
activeEnemy: null, // Currently targeted enemy
typedText: '' // Current typed input
};Edit constants in main.js:
// In CONFIG object
enemyBaseSpeed: 0.5, // Increase for faster enemies
spawnRate: 2000, // Decrease for more frequent spawns
maxEnemies: 5, // Increase for more enemies on screenEdit words.js to add custom words:
const wordLists = {
easy: ['cat', 'dog', 'run'], // 3-4 letters
medium: ['hello', 'world'], // 5-6 letters
hard: ['challenge', 'difficult'], // 7-9 letters
veryHard: ['extraordinary'] // 10+ letters
};Modify style.css for:
- Color schemes
- Font families
- Animation timings
- Responsive breakpoints
- Use ES6+ features (const/let, arrow functions, template literals)
- Follow camelCase for variables and functions
- Use descriptive variable names
- Comment complex logic
- New Game Mode: Extend
gameStateand add corresponding render/update logic - Power-ups: Add new object type to game loop
- Sound Effects: Integrate Web Audio API
- Multiplayer: Add WebSocket support for real-time gameplay
Enable debug mode by adding to main.js:
const DEBUG = true;
function render() {
// ... existing render code ...
if (DEBUG) {
// Draw debug info
ctx.fillStyle = 'white';
ctx.fillText(`FPS: ${fps}`, 10, 20);
ctx.fillText(`Enemies: ${enemies.length}`, 10, 40);
}
}- Object Pooling: Reuse enemy/particle objects instead of creating new ones
- Dirty Rectangles: Only redraw changed areas (not implemented)
- Request Animation Frame: Ensures smooth 60 FPS rendering
- Efficient Collision Detection: Simple bounding box checks
- Target: 60 FPS
- Canvas size: 800x600 (optimized for most displays)
- Memory: Minimal (no external dependencies)
- No object pooling (creates new objects each spawn)
- Full canvas redraw every frame
- No Web Workers for heavy computations
| Browser | Version | Status |
|---|---|---|
| Chrome | 60+ | ✅ Fully supported |
| Firefox | 55+ | ✅ Fully supported |
| Safari | 12+ | ✅ Fully supported |
| Edge | 79+ | ✅ Fully supported |
| IE 11 | - | ❌ Not supported |
- Canvas API
- Web Storage API (localStorage)
- requestAnimationFrame
- ES6+ JavaScript features
- Push code to GitHub repository
- Go to Settings → Pages
- Select source branch (usually
main) - Save and wait for deployment
- Access at
https://[username].github.io/[repo-name]/
# Install Netlify CLI
npm install -g netlify-cli
# Deploy
netlify deploy --prod# Install Vercel CLI
npm install -g vercel
# Deploy
vercel --prodUpload all files to your web server. No build step required.
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
- Add sound effects and background music -> Enabled with v2.0.0 🚀
- Implement power-ups (slow time, clear screen, etc.)
- Add different enemy types
- Create mobile touch controls
- Add leaderboard with backend integration
- Implement achievements system
- Add themes/skins
- Performance optimizations (object pooling)
This project is open source and available under the MIT License.
- Built with vanilla JavaScript (no frameworks)
- Inspired by classic typing games
- Uses HTML5 Canvas for rendering
For questions or issues, please open an issue on GitHub.