A Zelda-inspired adventure game designed for mobile devices and web browsers. Explore a vibrant world, battle enemies, collect treasures, and embark on an epic adventure!
- Cross-Platform: Runs on mobile devices and desktop browsers
- Touch Controls: Intuitive virtual joystick and action buttons for mobile
- Keyboard Support: WASD/Arrow keys + Space/X for desktop play
- Adventure Gameplay: Classic top-down Zelda-style action adventure
- Combat System: Sword attacks and magical sword beams
- Enemy AI: Smart enemies with patrol, chase, and attack behaviors
- Collectibles: Coins and power-ups scattered throughout the world
- Procedural World: Varied terrain with grass, water, forests, and stone areas
- Health System: Classic heart-based health system
- Particle Effects: Visual feedback for attacks and interactions
- Explore the world and defeat enemies
- Collect golden coins for points
- Survive as long as possible with your 3 hearts
Mobile/Touch:
- 📱 Virtual joystick (left side) to move your character
- ⚔️ Sword button (right side) to attack enemies
- 💫 At full health, attacks shoot magical sword beams!
Desktop/Keyboard:
- 🎮 WASD or Arrow Keys to move
- ⚔️ SPACE or X to attack
- 💫 Sword beams at full health!
- ❤️ You start with 3 hearts of health
- 👹 Green goblins are basic enemies - defeat them for 100 points each
- 💰 Golden coins give you 10 points and bob up and down
- 🌊 Avoid water tiles - you can't swim!
- 🌲 Trees and rocks block your movement
- 💫 Sword beams only work when you're at full health
- 🛡️ After taking damage, you're briefly invulnerable (flickering effect)
- Open
index.htmlin a web browser - The game will auto-detect if you're on mobile or desktop
- Follow the on-screen instructions
- Start your adventure!
- Clone this repository
- Install dependencies:
npm install - Start local server:
npm start - Open http://localhost:8080
npm run buildzelda-mobile-game/
├── index.html # Main HTML file with game canvas
├── package.json # Dependencies and scripts
├── js/
│ ├── main.js # Game initialization and UI
│ ├── game.js # Core game engine and loop
│ ├── player.js # Player character and combat
│ ├── enemy.js # Enemy AI and behavior
│ ├── world.js # World generation and rendering
│ └── controls.js # Input handling (touch + keyboard)
├── assets/
│ ├── images/ # Game sprites (placeholder)
│ └── sounds/ # Game audio (placeholder)
└── test/ # Unit tests
- HTML5 Canvas: High-performance 2D rendering
- Responsive Design: Adapts to different screen sizes
- Touch Events: Multi-touch support for mobile devices
- Game Loop: Smooth 60fps animation with delta timing
- State Management: Pause/resume functionality
- Camera System: Smooth camera following the player
- Collision Detection: Efficient rectangle-based collision system
- Particle System: Visual effects for impacts and collectibles
- Device Detection: Automatic mobile/desktop optimization
- Modern Browsers: Chrome, Firefox, Safari, Edge
- Mobile: iOS Safari, Chrome Mobile, Samsung Browser
- Features Used: ES6 Classes, Canvas 2D, Touch Events, RequestAnimationFrame
- New Enemies: Extend the
Enemyclass with different types - Power-ups: Add new collectible types to the world generation
- Weapons: Create new projectile types and attack patterns
- Levels: Implement level transitions and multiple worlds
- Audio: Add sound effects and background music
- The game automatically pauses when the tab is hidden
- Canvas rendering is optimized for mobile devices
- Only visible objects are rendered (camera culling)
- Particle systems have automatic cleanup
- Responsive canvas scaling
- Touch controls with visual feedback
- Optimized for portrait and landscape modes
- PWA-ready (can be added to home screen)
- Efficient rendering for battery life
- Water collision could be more precise
- Enemy pathfinding is basic (room for AI improvements)
- No save/load system yet
- Limited audio support
MIT License - Feel free to use this code for learning or building your own games!
This is a learning project, but contributions are welcome! Ideas for improvements:
- Add more enemy types and behaviors
- Implement a level/dungeon system
- Add more weapons and items
- Create sprite-based graphics
- Add sound effects and music
- Implement game save/load
- Add multiplayer support
Have fun exploring and may your adventure be legendary! ⚔️✨