A dual-mode game featuring both a Motato clone and tower defense, built with a modern WebGL2 engine, actual Motato sprites, and an Entity Component System architecture.
A faithful recreation of Motato with:
- Player-controlled character (WASD movement)
- Auto-attacking weapons
- Wave-based survival
- XP and level progression
- Real sprites from MotatoWithUnity
Strategic tower placement with:
- Multiple tower types
- Hype Burst & Momentum mechanics
- Special abilities and chain effects
- Wave modifiers and events
- Batch Rendering: Efficient sprite batching for optimal performance
- WebGL2 Shaders: Custom GLSL shaders for rendering shapes and sprites
- Fixed Timestep: Deterministic physics with fixed update rate
- Entity Component System: Flexible and maintainable game architecture
- Modular Design: Clean separation of concerns with multiple systems
- Rendering System: WebGL-based rendering with effects and animations
- Physics System: Movement, velocity, and collision detection
- Tower System: Automated targeting and shooting mechanics
- Enemy System: Path-following AI with various enemy types
- Bullet System: Projectile physics with homing and special effects
- Hype Burst: Build hype from kills and unleash for massive damage boost
- Momentum Frenzy: Chain kills rapidly to trigger a speed/power frenzy
- Wave Events: Dynamic modifiers that change gameplay each wave
- Multiple Tower Types: Basic, Pulse, Frost, Sniper, and Storm towers
- Special Effects: Chain lightning, splash damage, and slow effects
UTowerDefense/
โโโ index.html # Landing page / game mode selector
โโโ motato.html # Motato game mode
โโโ go.html # Tower defense (original)
โโโ towers.html # Tower defense (WebGL2 version)
โโโ assets/
โ โโโ sprites/ # Motato sprites from Unity
โ โโโ player/ # potato.png, legs.png, highlight.png
โ โโโ enemies/ # Enemy sprites
โ โโโ weapons/ # Weapon sprites
โ โโโ bullets/ # Bullet animations
โโโ src/
โ โโโ renderer/
โ โ โโโ WebGLRenderer.js # WebGL2 rendering engine
โ โ โโโ TextureLoader.js # Texture loading and caching
โ โโโ core/
โ โ โโโ Engine.js # Game loop and system management
โ โโโ ecs/
โ โ โโโ Entity.js # Entity and EntityManager
โ โ โโโ Components.js # Component definitions
โ โโโ systems/
โ โ โโโ RenderSystem.js # Rendering logic
โ โ โโโ PhysicsSystem.js # Physics and movement
โ โโโ game/
โ โโโ Game.js # Tower defense logic
โ โโโ MotatoGame.js # Motato game logic
โ โโโ GameState.js # Game state management
โโโ README.md
- Move: Use WASD or Arrow Keys
- Attack: Weapons automatically shoot nearest enemies
- Survive: Complete waves to earn money and XP
- Level Up: Gain stat boosts every level
- Wave Control: Start new waves when ready
- Select Tower: Click on a tower card
- Place: Click on canvas to place tower
- Start Wave: Begin the enemy assault
- Abilities: Use Hype Burst and momentum
- Strategy: Upgrade towers and use chain effects
The game works on GitHub Pages! Access via:
- Main page:
https://[username].github.io/UTowerDefense/ - Motato:
https://[username].github.io/UTowerDefense/motato.html - Tower Defense:
https://[username].github.io/UTowerDefense/go.html
The WebGLRenderer class provides a modern WebGL2 API for drawing:
- Circles (filled and outlined)
- Rectangles
- Lines
- Custom shapes with batching
Entities are composed of components:
- Transform: Position, rotation, scale
- Velocity: Movement vector
- Health: HP and armor
- Tower: Tower behavior and stats
- Enemy: Enemy AI and pathfinding
- Bullet: Projectile behavior
Systems process entities with specific components:
- PhysicsSystem: Updates positions based on velocity
- RenderSystem: Draws entities to the canvas
- Game: Handles tower shooting, enemy movement, collisions
- Orthographic projection matrix for 2D rendering
- Custom vertex and fragment shaders
- Efficient buffer management
- Alpha blending for transparency
- Batch rendering to minimize draw calls
- Efficient collision detection with spatial partitioning (future)
- Fixed timestep prevents physics issues
- Component-based architecture for cache efficiency
Based on the MotatoWithUnity repository analysis:
- Player-like progression systems
- Wave-based difficulty scaling
- Item and stat modifiers
- Chain and combo mechanics
- Visual feedback with effects
- Modern browser with WebGL2 support
- ES6 module support
- Local web server (for development)
# Using Python 3
python -m http.server 8000
# Using Node.js
npx http-server
# Then open http://localhost:8000- Define tower stats in
Game.getTowerData() - Add tower card to
TOWERSarray inindex.html - Implement special behavior in tower system if needed
- Create new component in
Components.js - Add system to process the component
- Update game logic in
Game.js
- Item shop between waves
- Multiple weapon types
- Stat modifiers and items
- More character sprites (different classes)
- Boss enemies
- Achievements and unlocks
- Tower upgrades UI
- More tower types
- Path editor
- Multiple difficulty levels
- Save/load game state
- Sound effects and music
- Particle system for better effects
- Mobile touch controls
- Leaderboards
- Multiplayer support
This project is open source and available for educational purposes.
- Inspired by Motato by Blobfish
- MotatoWithUnity reference implementation
- WebGL2 rendering techniques from various sources
Note: This is a modernized version using WebGL2 and ECS architecture. The original game logic has been preserved while the rendering engine has been completely rewritten for better performance and maintainability.