Skip to content

A mind-bending browser game that challenges players to navigate through four-dimensional space. Shift between W-layers of a 4D maze using ethereal visual hints and spatial audio to find the exit beacon. Features optimized rendering, procedural maze generation, and atmospheric dimensional effects.

Notifications You must be signed in to change notification settings

slaterhaus/maze-4d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ€ 4D Maze - Navigate Through Higher Dimensions

A mind-bending 4D maze game built with Babylon.js that challenges players to navigate through multiple dimensional layers to find the exit beacon.

4D Maze Screenshot

๐ŸŽฎ What Makes This Special

Experience navigation in four spatial dimensions - not just X, Y, Z, but also the mysterious W dimension. Each W-layer contains a complete 3D maze, and you must shift between these dimensional planes to reach your goal.

โœจ Key Features

  • ๐ŸŒŸ True 4D Navigation - Move through W-layers using Q/E keys to access different dimensional slices
  • ๐Ÿ‘ป Ethereal Dimensional Hints - Subtle ghost walls and particles show where walls exist in other dimensions
  • ๐ŸŽฏ Smart Goal Placement - AI ensures every maze is solvable with reachable exit beacons
  • ๐ŸŽจ Dynamic Visual Effects - Gentle dimensional distortions and atmospheric particles
  • ๐Ÿ”Š Spatial Audio - 3D positioned ambient sounds that respond to your movement
  • ๐Ÿ“Š Performance Monitoring - Real-time FPS and optimization metrics
  • โšก Optimized Rendering - Pre-generated geometry with intelligent layer switching

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 16+
  • Modern web browser with WebGL support

Installation

# Clone the repository
git clone https://github.com/yourusername/4d-maze-game.git
cd 4d-maze-game

# Install dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

๐ŸŽฏ How to Play

Basic Controls

  • Move: WASD or Arrow Keys
  • Look: Mouse (click to lock cursor)
  • Jump: Space
  • Sprint: Shift
  • Change W-Layer: Q (previous) / E (next)

Advanced Navigation

  • Help: H key to toggle help panel
  • New Maze: R key to generate fresh challenge
  • Exit Game: Esc to pause and unlock cursor

Understanding 4D Space

  1. Current Layer: The solid maze you can walk through
  2. Ghost Walls: Translucent walls showing barriers in other W-layers
  3. Portal Particles: Swirling effects indicate W-dimension passage points
  4. Exit Beacon: Golden glowing cylinder marking your destination
  5. Compass: HUD arrow points toward the exit with distance

Winning Strategy

  • Use the compass to navigate toward the exit beacon
  • If the exit isn't on your current W-layer, shift dimensions with Q/E
  • Ghost walls help you understand the maze structure across all dimensions
  • Portal particles show where you can move between W-layers

๐Ÿ—๏ธ Architecture

Modular Design

src/
โ”œโ”€โ”€ config.js              # Game configuration and constants
โ”œโ”€โ”€ main.js                 # Application entry point
โ”œโ”€โ”€ game-refactored.js      # Main game orchestration
โ”œโ”€โ”€ maze4d.js              # 4D maze generation algorithm
โ”œโ”€โ”€ Camera.js              # Player movement and controls
โ”œโ”€โ”€ MazeRenderer.js        # 3D geometry generation
โ”œโ”€โ”€ InputHandler.js        # Keyboard/mouse event management
โ”œโ”€โ”€ UI.js                  # HUD and overlay systems
โ”œโ”€โ”€ DimensionalEffects.js  # Visual effects and particles
โ”œโ”€โ”€ DimensionalAudio.js    # Spatial audio system
โ””โ”€โ”€ PerformanceMonitor.js  # FPS and performance tracking

Key Technologies

  • ๐ŸŽฎ Babylon.js - 3D rendering and physics
  • โšก Vite - Fast development and building
  • ๐ŸŽจ WebGL Shaders - Custom post-processing effects
  • ๐Ÿ”Š Web Audio API - Procedural spatial audio
  • ๐Ÿ“ 4D Mathematics - Higher-dimensional maze algorithms

๐Ÿ”ง Configuration

Edit src/config.js to customize:

export const GAME_CONFIG = {
  // Maze dimensions
  CELL_SIZE: 3,
  WALL_HEIGHT: 2.6,

  // Default maze size
  MAZE: {
    DEFAULT_W: 3,  // W-layers (4th dimension)
    DEFAULT_X: 8,  // Width
    DEFAULT_Z: 8   // Depth
  },

  // Camera settings
  CAMERA: {
    SPEED: 0.28,
    SPRINT_SPEED: 0.55,
    FOV: 1.2
  }
};

๐ŸŽจ Visual Effects System

Dimensional Rendering

  • Ghost Walls: Semi-transparent representations of walls in other W-layers
  • Particle Systems: Ethereal effects that hint at dimensional boundaries
  • Portal Indicators: Visual cues showing W-dimension transition points
  • Post-Processing: Subtle screen-space effects during dimensional shifts

Performance Optimizations

  • Pre-generation: All W-layers built at startup for instant switching
  • Material Pooling: Reused materials across maze generations
  • Selective Shadows: Only active geometry casts shadows
  • Culling: Invisible layers are completely disabled

๐Ÿ”Š Audio Design

Ambient Soundscape

  • Low-frequency drones create otherworldly atmosphere
  • 3D positioned sounds at portal locations
  • Dimensional shift audio during layer transitions
  • Adaptive intensity based on player proximity to rifts

๐ŸŽฏ Maze Generation Algorithm

Uses recursive backtracking in 4D space:

  1. Initialize 4D grid with all walls present
  2. Start from random cell in 4D space
  3. Carve paths by removing walls between visited cells
  4. Ensure connectivity across all four dimensions
  5. Smart goal placement finds farthest reachable cell from start

๐Ÿš€ Performance Features

  • Real-time FPS monitoring with performance grading (A-F)
  • Active mesh counting for optimization insights
  • Memory usage tracking (where supported)
  • Performance stability metrics with variance analysis

๐ŸŽฎ Controls Reference

Action Keys Description
Move Forward W, โ†‘ Walk forward
Move Backward S, โ†“ Walk backward
Strafe Left A, โ† Move left
Strafe Right D, โ†’ Move right
Look Around Mouse Camera rotation
Jump Space Hop over small obstacles
Sprint Shift Move faster
W-Layer Back Q Previous dimensional layer
W-Layer Forward E Next dimensional layer
Toggle Help H Show/hide help panel
New Maze R Generate fresh challenge
Pause Esc Unlock cursor

๐Ÿ› ๏ธ Development

Code Style

  • ES6+ modules with clean imports/exports
  • Functional programming patterns where appropriate
  • Event-driven architecture for loose coupling
  • Configuration-first design for easy customization

Performance Considerations

  • Pre-generate geometry for instant W-layer switching
  • Use object pooling for frequently created/destroyed objects
  • Implement selective shadow casting to reduce GPU load
  • Monitor performance metrics in real-time

Adding New Features

  1. Visual Effects: Extend DimensionalEffects.js
  2. Audio: Enhance DimensionalAudio.js
  3. Maze Algorithms: Modify maze4d.js
  4. UI Elements: Update UI.js
  5. Configuration: Adjust config.js

๐Ÿ“Š Technical Specifications

  • Minimum: WebGL 1.0, 2GB RAM, 60 FPS target
  • Recommended: WebGL 2.0, 4GB RAM, 120 FPS capable
  • Browser Support: Chrome 70+, Firefox 65+, Safari 12+, Edge 79+

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Test thoroughly across different browsers
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Development Guidelines

  • Maintain modular architecture
  • Add comprehensive comments for complex 4D math
  • Test performance impact of new features
  • Follow existing code style and patterns

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Babylon.js Team - Incredible 3D engine
  • 4D Mathematics Community - Inspiration for higher-dimensional navigation
  • Web Audio API - Enabling procedural spatial audio
  • Modern Web Standards - Making browser-based 3D gaming possible

๐Ÿ”— Links


Experience navigation beyond the third dimension. Can you master the 4D maze? ๐ŸŒ€

About

A mind-bending browser game that challenges players to navigate through four-dimensional space. Shift between W-layers of a 4D maze using ethereal visual hints and spatial audio to find the exit beacon. Features optimized rendering, procedural maze generation, and atmospheric dimensional effects.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published