Skip to content

karolswdev/kula

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

36 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Kula Browser - Gravity-Defying 3D Puzzle Platformer

Three.js JavaScript CANNON.js License: MIT

๐ŸŒ Defy gravity. Master momentum. Conquer impossible worlds. ๐ŸŒ

A browser-based recreation of the classic Kula World, where physics bends to your will

Play Demo โ€ข Watch Gameplay โ€ข Report Bug โ€ข Request Feature


๐ŸŽฏ Game Overview

Kula Browser reimagines the beloved puzzle-platformer experience for the modern web. Navigate a mysterious sphere through mind-bending levels where gravity is just a suggestion, momentum is your ally, and every surface could become your floor.

What Makes This Special?

This isn't just another 3D platformer. Kula Browser challenges your spatial reasoning and reflexes in ways that traditional games can't:

  • 360ยฐ Freedom: Every surface is potentially walkable - walls become floors at your command
  • Physics-Based Puzzles: Master momentum conservation through gravity shifts to reach impossible places
  • Strategic Gameplay: Plan your route carefully - one wrong gravity shift could leave you stranded
  • Progressive Difficulty: From gentle introductions to mind-melting challenges that will test your mastery

Why You'll Love It

  • ๐ŸŽฎ Pick Up and Play: Simple controls, deep mechanics
  • ๐Ÿง  Brain-Teasing Puzzles: Each level is a spatial reasoning challenge
  • โšก Smooth Performance: 60 FPS gameplay optimized for all modern browsers
  • ๐ŸŽฏ Clear Objectives: Collect keys, reach the exit, master the physics
  • ๐Ÿ”„ Endless Replayability: Perfect your routes, beat your times, master every level

โœจ Features

Core Gameplay

  • ๐Ÿ”„ Gravity Manipulation: Shift gravity in 6 directions with Q/E keys
  • ๐ŸŽฎ Smooth Physics: Realistic ball physics with momentum conservation
  • ๐Ÿ—๏ธ Key Collection: Strategic objectives that unlock level completion
  • ๐Ÿšช Dynamic Exits: Exits that activate only when all keys are collected
  • ๐Ÿ’€ Environmental Hazards: Deadly spikes and moving platforms to avoid
  • ๐Ÿƒ Moving Platforms: Dynamic level elements that add timing challenges

Technical Excellence

  • ๐ŸŽจ Three.js Rendering: Beautiful 3D graphics powered by WebGL
  • โš™๏ธ CANNON.js Physics: Realistic physics simulation for authentic gameplay
  • ๐Ÿ“ฑ Responsive Design: Adapts to any screen size and resolution
  • ๐ŸŽต Immersive Audio: Sound effects for every action and event
  • ๐Ÿ“Š HUD System: Real-time display of lives, score, and objectives
  • ๐ŸŽฏ Smart Camera: Intelligent camera that follows action smoothly

Architecture

  • ๐Ÿ—๏ธ Modular Design: Clean, maintainable code architecture
  • ๐Ÿ“ JSON Levels: Data-driven level system for easy content creation
  • ๐Ÿ”Œ Event System: Decoupled components communicate via events
  • ๐Ÿงช Test Coverage: Comprehensive E2E tests with Playwright
  • ๐Ÿ“ฆ Zero Framework Dependencies: Pure vanilla JavaScript for maximum performance

๐Ÿ› ๏ธ Technical Stack

Technology Purpose Why We Chose It
Three.js 3D Rendering Industry-standard WebGL library with excellent documentation
CANNON.js Physics Engine Lightweight, fast, perfect for web-based physics
Vanilla JavaScript Core Logic No framework overhead, maximum performance
Playwright E2E Testing Modern testing framework with great debugging tools
Webpack Module Bundling Efficient bundling and optimization
ES6 Modules Code Organization Clean, modern module system

๐Ÿš€ Getting Started

Prerequisites

  • Node.js (v14.0.0 or higher)
  • npm (v6.0.0 or higher)
  • Modern web browser (Chrome, Firefox, Safari, Edge)

Installation

# Clone the repository
git clone https://github.com/yourusername/kula-browser.git

# Navigate to project directory
cd kula-browser

# Install dependencies
npm install

# Start the development server
npm start

Running the Game

  1. Development Mode:

    npm start

    Opens the game at http://localhost:8080

  2. Production Build:

    npm run build

    Creates optimized build in dist/ directory

  3. Run Tests:

    npm test        # Run all tests
    npm run test:e2e # Run E2E tests only

๐ŸŽฎ How to Play

Controls

Action Key/Input Description
Move Forward W Roll the ball forward
Move Backward S Roll the ball backward
Move Left A Roll the ball left
Move Right D Roll the ball right
Jump Space Make the ball jump
Gravity Left Q Shift gravity 90ยฐ left
Gravity Right E Shift gravity 90ยฐ right
Camera Mouse Look around (click and drag)

Objectives

  1. ๐Ÿ—๏ธ Collect All Keys: Find and collect all yellow keys scattered throughout the level
  2. ๐Ÿšช Unlock the Exit: The exit portal activates only after all keys are collected
  3. โš ๏ธ Avoid Hazards: Don't touch red spikes or fall into the void
  4. โฑ๏ธ Master Your Time: Complete levels as quickly as possible for the best score

Pro Tips

  • Momentum Matters: Your velocity carries through gravity shifts - use it wisely!
  • Plan Your Route: Survey the level before making risky gravity changes
  • Jump + Gravity: Combine jumps with gravity shifts for advanced maneuvers
  • Edge Safety: Be careful near edges when shifting gravity
  • Platform Timing: Study moving platform patterns before attempting crosses

๐Ÿ—๏ธ Architecture

System Design

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     Game Controller                      โ”‚
โ”‚                  (Main Game Loop & State)                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                                    โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”                        โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”
    โ”‚  Physics โ”‚                        โ”‚ Renderer โ”‚
    โ”‚  Manager โ”‚                        โ”‚  (Three) โ”‚
    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜                        โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                                    โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Core Systems                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   Player     โ”‚   Camera     โ”‚    Level     โ”‚    UI     โ”‚
โ”‚ Controller   โ”‚ Controller   โ”‚   Manager    โ”‚  Manager  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                                    โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  Entity Components                       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   Platform   โ”‚     Key      โ”‚    Hazard    โ”‚   Exit    โ”‚
โ”‚   Entity     โ”‚   Entity     โ”‚   Entity     โ”‚  Entity   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Modules

  • ๐ŸŽฎ Game.js: Main game controller and state management
  • โšฝ PlayerController.js: Ball movement, jumping, and gravity control
  • โš™๏ธ PhysicsManager.js: CANNON.js integration and physics simulation
  • ๐Ÿ“ท CameraController.js: Smooth camera following and user input
  • ๐Ÿ—บ๏ธ LevelManager.js: Level loading, entity creation, and management
  • ๐Ÿ“Š UIManager.js: HUD rendering and user interface updates
  • ๐ŸŽต AudioManager.js: Sound effect management and playback
  • ๐ŸŽฏ EventBus.js: Central event system for component communication

Event Flow

// Example: Key Collection Flow
PlayerController โ†’ Collision โ†’ EventBus.emit('keyCollected')
                                    โ†“
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ†“                               โ†“                   โ†“
UIManager.updateScore()    LevelManager.checkWin()  AudioManager.playSound()

๐Ÿงช Testing

Test Coverage

Our comprehensive test suite ensures reliability and stability:

  • โœ… E2E Tests: Full gameplay scenarios with Playwright
  • โœ… Integration Tests: Component interaction verification
  • โœ… Regression Tests: Ensuring new features don't break existing ones
  • โœ… Performance Tests: FPS and rendering optimization checks

Running Tests

# Run all tests
npm test

# Run E2E tests with UI
npm run test:e2e:ui

# Run specific test suite
npm run test -- --grep "gravity"

# Generate coverage report
npm run test:coverage

Test Categories

  1. Core Mechanics: Movement, jumping, gravity shifts
  2. Level Systems: Loading, entity creation, objectives
  3. Collision Detection: Player-entity interactions
  4. Game States: Win/lose conditions, score tracking
  5. Performance: Frame rate, memory usage, load times

๐ŸŽจ Level Design

Level Format

Levels are defined in JSON for easy creation and modification:

{
  "name": "Gravity Garden",
  "difficulty": "medium",
  "par_time": 120,
  "spawn": { "x": 0, "y": 5, "z": 0 },
  "platforms": [
    {
      "position": { "x": 0, "y": 0, "z": 0 },
      "size": { "x": 10, "y": 1, "z": 10 },
      "color": "#4CAF50",
      "type": "static"
    }
  ],
  "keys": [
    {
      "id": "key1",
      "position": { "x": 5, "y": 2, "z": 5 },
      "color": "#FFD700"
    }
  ],
  "hazards": [
    {
      "type": "spike",
      "position": { "x": -3, "y": 1, "z": 0 },
      "damage": 1
    }
  ],
  "exit": {
    "position": { "x": 0, "y": 2, "z": -8 },
    "requiredKeys": ["key1", "key2", "key3"]
  }
}

Creating Custom Levels

  1. Create a new JSON file in assets/levels/
  2. Define platforms, keys, hazards, and exit
  3. Add to level registry in LevelManager.js
  4. Test thoroughly with different gravity orientations

Entity Types

Entity Purpose Properties
Platform Walkable surfaces position, size, color, movement
Key Collectible objectives position, id, color, value
Hazard Damage sources position, type, damage, pattern
Exit Level completion position, requiredKeys, nextLevel
Moving Platform Dynamic obstacles position, size, path, speed

๐ŸŽจ Level Editor

Accessing the Editor

The Kula Browser includes a powerful in-browser level editor that allows you to create custom levels with an intuitive 3D interface.

To access the editor:

  1. Open editor.html in your browser
  2. Or navigate to http://localhost:8080/editor.html when running the dev server

Floor-Based Editing System

The editor uses a floor-based editing system that makes it easy to work in 3D space:

  • Current Floor Lock: You can only place/edit blocks on the currently selected floor
  • Visual Hierarchy:
    • Current floor: Full visibility with grid
    • Floors below: Semi-transparent (25% opacity)
    • Floors above: Very faint (10% opacity)
  • Precise Placement: No more guessing which grid cell you're clicking on!

Editor Controls

Floor Navigation

Action Controls Description
Move Up One Floor PageUp or Shift+Q Navigate to the floor above
Move Down One Floor PageDown or Shift+E Navigate to the floor below
Jump to Floor Alt+0 to Alt+9 Instantly jump to floor 0-9
Direct Input Floor input field Type exact floor number (-5 to 10)
Visual Buttons โ–ฒ/โ–ผ buttons Click to move up/down floors

Tool Selection

Tool Shortcut Description
Place Q Place blocks at cursor position
Remove W Remove blocks at cursor position
Select E Select blocks for properties

Block Selection

Action Shortcut Description
Quick Select 1-9 Select block type from palette
Mouse Select Click palette Choose from visual block palette

Camera Controls

Action Control Description
Rotate Left Mouse Drag Orbit camera around focus point
Zoom Mouse Wheel Zoom in/out
Pan Right Mouse Drag Move camera laterally

Creating a Level

  1. Start with Floor 0: The editor starts at floor 0 by default
  2. Place Platform Blocks: Select a platform type and click to place
  3. Add Player Spawn: Place the green sphere where the player starts
  4. Add Keys: Place golden cones that the player must collect
  5. Add Exit: Place the purple ring that ends the level
  6. Add Hazards: Optionally add spikes and other obstacles
  7. Test Different Floors: Use floor navigation to build vertically
  8. Generate JSON: Click "Generate JSON" to export your level

Level Requirements

For a valid, playable level you must include:

  • โœ… Player Spawn Point (green sphere)
  • โœ… At least one Key (golden cone)
  • โœ… Exit Portal (purple ring)
  • โœ… Platform blocks for the player to walk on

Tips for Effective Level Creation

  1. Start Simple: Begin with a flat layout on floor 0
  2. Build Upward: Use floors 1-3 for vertical challenges
  3. Test Accessibility: Ensure all areas are reachable
  4. Use Visual Cues: Place decorations to guide players
  5. Mind the Gaps: Remember the ball can jump ~1.5 grid units
  6. Preview Other Floors: Check alignment between floors
  7. Save Often: Generate JSON periodically to save your work

Importing/Exporting Levels

Export Level

  1. Click "Generate JSON" button
  2. Copy the JSON from the text area
  3. Save to a .json file in levels/ directory

Import Level

  1. Click "Load JSON" button
  2. Select your .json level file
  3. The level will load in the editor for editing

Advanced Features

  • Grid Size Adjustment: Change the grid size for larger/smaller levels
  • Theme Selection: Choose between different visual themes
  • Block Behaviors: Some blocks have special behaviors (moving platforms, etc.)
  • Multi-Floor Puzzles: Create complex vertical challenges using gravity mechanics

๐Ÿค Contributing

We welcome contributions from the community! Here's how you can help:

How to Contribute

  1. Fork the Repository: Click the Fork button at the top of this page
  2. Clone Your Fork: git clone https://github.com/yourusername/kula-browser.git
  3. Create a Branch: git checkout -b feature/amazing-feature
  4. Make Changes: Implement your feature or fix
  5. Test Thoroughly: Run all tests and add new ones if needed
  6. Commit: git commit -m 'feat: add amazing feature'
  7. Push: git push origin feature/amazing-feature
  8. Open PR: Submit a Pull Request with a clear description

Code Style Guidelines

  • Use ES6+ features where appropriate
  • Follow existing code patterns and architecture
  • Comment complex logic and algorithms
  • Write self-documenting code with clear variable names
  • Add JSDoc comments for public methods
  • Ensure all tests pass before submitting

Testing Requirements

  • Add E2E tests for new features
  • Maintain or improve code coverage
  • Test across different browsers
  • Verify performance impact

๐Ÿ—บ๏ธ Roadmap

Version 1.0 (Current)

  • โœ… Core gameplay mechanics
  • โœ… 5 introductory levels
  • โœ… Basic hazards and moving platforms
  • โœ… Sound effects and HUD
  • โœ… Full test coverage

Version 1.1 (Next)

  • ๐Ÿ”„ 10 additional levels with increasing difficulty
  • ๐Ÿ”„ New hazard types (lasers, crushers, teleporters)
  • ๐Ÿ”„ Time trial mode with leaderboards
  • ๐Ÿ”„ Level restart and checkpoint system

Version 2.0 (Future)

  • โœ… In-browser level editor (Implemented!)
  • ๐ŸŒ Community level sharing
  • ๐Ÿ† Achievement system
  • ๐ŸŽฎ Gamepad support
  • ๐Ÿ“ฑ Mobile touch controls
  • ๐Ÿ‘ฅ Local multiplayer races

Long-term Vision

  • ๐ŸŒ Online multiplayer
  • ๐ŸŽจ Custom ball skins and trails
  • ๐ŸŽต Dynamic music system
  • ๐Ÿ—๏ธ Workshop/modding support
  • ๐ŸŽฏ Daily challenges
  • ๐Ÿ“Š Global leaderboards

๐Ÿš€ Development Journey

The Five Phases

This game was built following a rigorous test-driven development approach across five phases:

  1. Phase 1 - Core Engine: Three.js setup, basic physics, player controller
  2. Phase 2 - Gravity System: 6-directional gravity, momentum conservation
  3. Phase 3 - Level Objectives: Keys, exits, level loading system
  4. Phase 4 - Game Systems: Score, lives, HUD, audio integration
  5. Phase 5 - Polish: Hazards, moving platforms, visual effects

Key Challenges Overcome

  • ๐Ÿ”„ Gravity Transitions: Smooth camera reorientation during gravity shifts
  • โšก Performance: Maintaining 60 FPS with complex physics calculations
  • ๐ŸŽฏ Precision: Pixel-perfect collision detection for tight platforming
  • ๐Ÿ“ Spatial Logic: Intuitive controls regardless of gravity orientation
  • ๐ŸŽจ Visual Clarity: Clear visual communication of game state

Performance Optimizations

  • Object pooling for entities
  • Efficient collision detection with spatial partitioning
  • Texture atlasing for reduced draw calls
  • LOD system for distant objects
  • Optimized shader usage

๐Ÿ‘ Credits

Development Team

  • Human Developer: Project vision, requirements, and guidance
  • Claude AI Assistant: Implementation, architecture, and testing
  • Collaboration: A testament to human-AI pair programming

Inspiration

  • Kula World (1998): The original PlayStation classic that inspired this project
  • Portal Series: Spatial puzzle design philosophy
  • Super Mario Galaxy: Gravity mechanic inspiration

Technologies & Libraries

Special Thanks

  • The Three.js community for excellent documentation
  • Open source contributors who make projects like this possible
  • Classic game developers who inspire new generations

๐Ÿ“„ License

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

MIT License

Copyright (c) 2025 Kula Browser Development Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...

๐Ÿ“ž Contact


๐ŸŽฎ Ready to defy gravity?

Play Now | Watch Gameplay | Join Discord

Made with โค๏ธ and physics

"In a world where up is down and walls are floors, only the skilled survive."

About

A recreation of the Kula World Game for your favorite browser

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors