Mystic Realm Defender is a 2D magical survival game developed during the first Vibe Gaming Hackathon in LATAM as part of Buenos Aires Tech Week. Control a powerful wizard and defend the mystical realm by surviving infinite waves of mythological creatures using powerful spells and magical abilities.
- Infinite wave system with exponential difficulty scaling every 10 waves
- 6 distinct creature types including normal, caster, tank, speed, explosive, and boss enemies
- Advanced AI pathfinding with A* algorithm and collision avoidance
- Progressive spell upgrade system with 6 levels (0-5) of magical power
- Health pack system for survival strategy
- Mobile-responsive with virtual controls for touch devices
- Spell Levels (0-5): Each level enhances casting abilities
- Level 0: Single projectile (250ms cooldown)
- Level 1: Faster casting (200ms cooldown)
- Level 2: Double projectile spread (180ms cooldown)
- Level 3: Larger projectiles (160ms cooldown, 150% size)
- Level 4: Triple projectile barrage (150ms cooldown)
- Level 5: Quadruple spell storm (120ms cooldown, 200% size)
- Normal Creatures: Basic pursuers (30 HP base, 3 crystals reward)
- Caster Creatures: Ranged spell attackers (50 HP base, 7 crystals reward)
- Tank Creatures: High HP, slow movement (120 HP base, 10 crystals reward)
- Speed Creatures: Fast but fragile (15 HP base, 5 crystals reward)
- Explosive Creatures: Explode on death (25 HP base, 8 crystals reward)
- Boss Creatures: Massive enemies every 5 waves (300 HP base, 50 crystals reward)
- Top 3 highest scores from the greatest wizards
- Complete history of magical battles
- Global statistics with total realms defended
- Real-time persistence with Supabase magic
Desktop:
WASD / Arrow Keys โ Wizard movement
Spacebar โ Cast spells in movement direction
ESC โ Exit fullscreen
F โ Toggle fullscreen
Mobile:
Virtual Joystick โ Movement
Fire Button โ Cast spells in movement direction
- Survive infinite waves of increasingly difficult mythological creatures
- Collect crystals from defeated enemies to purchase upgrades
- Use the Arcane Shop between waves to enhance spells and health
- Compete globally for the highest score on the leaderboard
- Master the spell system to achieve maximum magical power
- Next.js 15 - React framework with App Router architecture
- TypeScript - Full type safety across the entire codebase
- HTML5 Canvas - Custom 2D game engine with 60 FPS rendering
- React 19 - Latest React with concurrent features
- Tailwind CSS - Utility-first styling with custom magical theme
- Supabase - PostgreSQL database with real-time subscriptions
- Row Level Security (RLS) - Secure data access controls
- Edge Functions - Serverless API endpoints for game logic
- Bun - Ultra-fast JavaScript runtime and package manager
- Biome - Fast linter and formatter (ESLint + Prettier alternative)
- PostCSS - CSS processing with plugins
- Vercel Analytics - Performance and usage tracking
- Pixel art sprites - Custom wizard, creature, and effect assets
- Press Start 2P font - Retro gaming typography
- Custom particle systems - Crystal collection and floating effects
- Bun (recommended) or Node.js 18+
- Git
- Supabase account for database functionality
- Clone the repository
git clone https://github.com/decker-dev/wizard-game-react
cd wizard-game-react
- Install dependencies
# With Bun (recommended for speed)
bun install
# Or with npm
npm install
- Environment configuration
# Create .env.local file
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
- Database setup
-- Execute in Supabase SQL Editor:
-- sql/create_tables.sql contains all necessary table schemas
- Start development server
bun dev
# Runs on http://localhost:3001
CREATE TABLE leaderboard (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
player_name VARCHAR(50) NOT NULL,
score INTEGER DEFAULT 0,
waves_survived INTEGER DEFAULT 0,
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE TABLE game_stats (
id SERIAL PRIMARY KEY,
stat_type VARCHAR(50) NOT NULL UNIQUE,
total_games_played INTEGER DEFAULT 0,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
๐ฆ mystic-realm-defender/
โโโ ๐ app/ # Next.js App Router
โ โโโ ๐ game/ # Game page route (/game)
โ โโโ ๐ credits/ # Credits page (/credits)
โ โโโ ๐ settings/ # Settings page (/settings)
โ โโโ ๐ api/ # API routes
โ โ โโโ validate-score/ # Score validation endpoint
โ โโโ layout.tsx # Root layout with fonts and analytics
โ โโโ page.tsx # Home page component
โ โโโ globals.css # Global styles and Tailwind base
โ โโโ manifest.ts # PWA manifest configuration
โ โโโ sitemap.ts # SEO sitemap generation
โโโ ๐ components/ # React UI Components
โ โโโ GameScreen.tsx # Main game orchestration component
โ โโโ GameCanvas.tsx # Canvas rendering and game loop
โ โโโ GameUI.tsx # In-game interface (health, score, wave)
โ โโโ Marketplace.tsx # Upgrade shop between waves
โ โโโ Leaderboard.tsx # Score rankings display
โ โโโ MobileControls.tsx # Touch controls for mobile devices
โ โโโ GameOverlay.tsx # Game state overlays (pause, game over)
โ โโโ ScoreSubmissionModal.tsx # Score submission and sharing
โ โโโ HomeScreen.tsx # Main menu and navigation
โ โโโ LoadingScreen.tsx # Asset loading screen
โ โโโ ShareModal.tsx # Social sharing functionality
โ โโโ CoinParticles.tsx # Crystal collection effects
โ โโโ FloatingParticles.tsx # Background ambient effects
โ โโโ CoinIcon.tsx # Crystal currency icon
โโโ ๐ hooks/ # Custom React Hooks
โ โโโ useGameController.ts # Main game state orchestration
โ โโโ useGameState.ts # Game entity state management
โ โโโ useAssetLoader.ts # Sprite and texture loading
โ โโโ useInputHandlers.ts # Keyboard and mouse input
โ โโโ useGameAudio.ts # Sound effects and music system
โ โโโ useLeaderboard.ts # Score persistence and retrieval
โ โโโ useGameScreens.ts # Screen state management
โโโ ๐ game/ # Core Game Logic
โ โโโ Player.ts # Wizard character controller
โ โโโ Creatures.ts # Enemy AI and behavior systems
โ โโโ Projectiles.ts # Spell and magic bolt physics
โ โโโ Collisions.ts # AABB collision detection
โ โโโ Renderer.ts # Canvas rendering engine
โโโ ๐ utils/ # Utility Functions
โ โโโ math.ts # Vector mathematics and physics
โ โโโ marketplace.ts # Upgrade cost calculations
โ โโโ coinParticles.ts # Particle effect systems
โโโ ๐ types/ # TypeScript Definitions
โ โโโ game.ts # Game entity interfaces and types
โโโ ๐ constants/ # Game Configuration
โ โโโ game.ts # Balancing constants and settings
โโโ ๐ data/ # Static Game Data
โ โโโ obstacles.ts # Map obstacle definitions
โ โโโ mapLayouts/ # Level layout configurations
โโโ ๐ lib/ # External Integrations
โ โโโ supabase.ts # Database client configuration
โ โโโ metadata.ts # SEO and PWA metadata
โโโ ๐ public/ # Static Assets
โ โโโ ๐ wizard/ # Player character sprite sheets
โ โโโ ๐ creature/ # Normal enemy sprites
โ โโโ ๐ mage/ # Caster enemy sprites
โ โโโ ๐ health/ # Health pack sprites
โ โโโ ๐ explosive/ # Explosive creature sprites (WIP)
โ โโโ floor-texture.png # Game background texture
โ โโโ og.png # Social media preview image
โ โโโ favicon.ico # Site favicon
โโโ ๐ sql/ # Database Scripts
โ โโโ create_tables.sql # Supabase table schemas
โโโ ๐ styles/ # Additional Stylesheets
# Development
bun dev # Start development server on port 3001
bun build # Build optimized production bundle
bun start # Start production server
# Code Quality
bun lint # Run Next.js linting
- 60 FPS rendering with requestAnimationFrame optimization
- Object pooling for projectiles to prevent memory leaks
- Spatial partitioning for efficient collision detection
- Sprite animation system with directional character movement
- Camera system with smooth player following and map boundaries
- A pathfinding* for intelligent navigation around obstacles
- Steering behaviors including seek, flee, separation, and obstacle avoidance
- Line of sight optimization for performance
- Behavioral patterns unique to each creature type
- Responsive detection with automatic mobile optimization
- Virtual controls with customizable joystick and fire button
- Touch gesture support for smooth mobile gameplay
- Fullscreen API integration for immersive experience
- Efficient rendering with dirty rectangle updates
- Memory management with proper cleanup cycles
- Asset preloading for smooth gameplay experience
- Debounced input handling for responsive controls
This project was developed during the Vibe Gaming Hackathon LATAM, part of Buenos Aires Tech Week 2024.
- โ Complete game with full gameplay loop
- โ 6 enemy types with unique behaviors and AI
- โ Progressive difficulty system with infinite scaling
- โ Real-time leaderboard with global competition
- โ Mobile compatibility with touch controls
- โ Polish and effects including particle systems
- โ Deployment on production infrastructure
We welcome contributions to enhance the mystical realm! Here's how to get involved:
- Fork the repository
- Create a feature branch (
git checkout -b feature/enhanced-spells
) - Implement your changes with TypeScript
- Test thoroughly on both desktop and mobile
- Add patch notes for your changes (see Patch Notes Requirements below)
- Submit a pull request with detailed description
All pull requests MUST include patch notes describing what was added, modified, or improved:
- Update
/data/patchNotes.ts
with your changes - Follow the existing format with proper categorization:
NEW
โจ - New features or contentIMPROVED
โก - Enhancements to existing featuresFIXED
๐ง - Bug fixes and correctionsBALANCED
โ๏ธ - Game balance adjustments
- Include version number following semantic versioning (e.g., v1.2.3)
- Write clear descriptions of what changed and why
- Add your changes to the top of the patch notes array
Example patch note entry:
{
version: "v1.3.0",
title: "Enhanced Spell System",
date: "2025-06-XX",
description: "Major improvements to spell casting mechanics",
changes: [
{
category: "NEW",
items: [
"Added spell combo system for advanced players",
"New visual effects for level 5 spells"
]
},
{
category: "IMPROVED",
items: [
"Spell casting now feels more responsive",
"Better projectile collision detection"
]
}
]
}
- ๐จ New sprites for explosive and speed creatures
- ๐ต Audio system enhancements and sound effects
- ๐ฎ New creature types with unique behaviors
- ๐ Game balance improvements and testing
- ๐ Accessibility features and improvements
This project is licensed under the GNU General Public License v3.0 (GPL-3.0).
Mystic Realm Defender - A 2D magical survival game with infinite waves of mythological creatures
Copyright (C) 2025 Lauti, Alejo, and Decker (Vibe Gaming Hackathon Team)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
For more details, see the LICENSE file.
- ๐ฎ Play the Game: mystic.decker.sh
- ๐ Hackathon Event: Paisanos.io Vibe Gaming
- ๐ฆ Developers: