Skip to content

Stop the running bunny! - an addictive puzzle game to predict the motion of a running buy and block its way

License

Notifications You must be signed in to change notification settings

paradox-solver/BunnyRunAway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿฐ Bunny Runaway Web

License: GPL-3.0 Platform Play Online

An open-source and modular JavaScript game project featuring intelligent pathfinding and a modern UI. This repository is intended for developers and learners interested in game architecture, AI, and browser-based game development.

๐Ÿ”—Links

๐ŸŽฏ Project Highlights

  • AI Pathfinding: A* algorithm for smart bunny movement
  • Responsive Design: Works across devices and browsers
  • Modular Codebase: Clean, maintainable, and extensible structure
  • Modern UI: Attractive interface and smooth user experience

๐Ÿ“ŒRequirements

  • Any modern web browser (Chrome, Firefox, Edge, Safari, etc.)
  • Interpreter, one of the following two:
    • Python 3.x (recommended for running a simple local server with python -m http.server)
    • Node.js (optional, only if you want to use npm-based static servers or install dependencies)
  • No build tools or package managers are required for basic development and running the game
  • No JavaScript framework knowledge is needed; the project uses plain JavaScript (ES6+)
  • If you want to modify or extend the code, a basic understanding of JavaScript modules and browser developer tools is helpful

๐Ÿš€ Getting Started

Development Environment

You can run the game locally using any static file server. For example:

# Start a development server (Node.js required)
python -m http.server 8000
# or
npm install -g serve
serve .

# Then open
# http://localhost:8000/index.html

๐Ÿ“ Project Structure

BunnyRunAway/
โ”œโ”€โ”€ src/                          # Source code
โ”‚   โ”œโ”€โ”€ app.js                    # Application entry point
โ”‚   โ”œโ”€โ”€ core/                     # Core game systems
โ”‚   โ”‚   โ”œโ”€โ”€ GameController.js     # Game controller
โ”‚   โ”‚   โ”œโ”€โ”€ GameEngine.js         # Game engine
โ”‚   โ”‚   โ”œโ”€โ”€ GameLoop.js           # Game loop
โ”‚   โ”‚   โ”œโ”€โ”€ UIManager.js          # UI manager
โ”‚   โ”‚   โ”œโ”€โ”€ EventHandler.js       # Event handler
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ managers/                 # Managers
โ”‚   โ”‚   โ”œโ”€โ”€ GameInitializer.js    # Game initializer
โ”‚   โ”‚   โ”œโ”€โ”€ ConfigManager.js      # Configuration manager
โ”‚   โ”‚   โ”œโ”€โ”€ AudioManager.js       # Audio manager
โ”‚   โ”‚   โ”œโ”€โ”€ DialogManager.js      # Dialog manager
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ services/                 # Game services
โ”‚   โ”‚   โ”œโ”€โ”€ Bunny.js              # Bunny AI
โ”‚   โ”‚   โ”œโ”€โ”€ MapService.js         # Map service
โ”‚   โ”‚   โ”œโ”€โ”€ BlockerService.js     # Blocker service
โ”‚   โ”‚   โ”œโ”€โ”€ DocumentationService.js # Documentation service
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ””โ”€โ”€ utils/                    # Utilities
โ”‚       โ”œโ”€โ”€ CanvasRenderer.js     # Canvas renderer
โ”‚       โ”œโ”€โ”€ CanvasCoordinateHelper.js # Coordinate helper
โ”‚       โ”œโ”€โ”€ responsive-helper.js  # Responsive helper
โ”‚       โ””โ”€โ”€ ...
โ”œโ”€โ”€ css/                          # Stylesheets
โ”‚   โ”œโ”€โ”€ main.css                  # Main styles
โ”‚   โ”œโ”€โ”€ components.css             # ็ป„ไปถๆ ทๅผ
โ”‚   โ”œโ”€โ”€ dialogs.css                # ๅฏน่ฏๆก†ๆ ทๅผ
โ”‚   โ””โ”€โ”€ responsive.css              # ๅ“ๅบ”ๅผๆ ทๅผ
โ”œโ”€โ”€ assets/                        # ้™ๆ€่ต„ๆบ
โ”‚   โ”œโ”€โ”€ maps/                      # ๅœฐๅ›พๆ•ฐๆฎ
โ”‚   โ”‚   โ”œโ”€โ”€ easy/                  # ็ฎ€ๅ•้šพๅบฆๅœฐๅ›พ
โ”‚   โ”‚   โ””โ”€โ”€ hard/                  # ๅ›ฐ้šพ้šพๅบฆๅœฐๅ›พ
โ”‚   โ”œโ”€โ”€ backgrounds/               # ่ƒŒๆ™ฏๅ›พ็‰‡
โ”‚   โ”œโ”€โ”€ sprites/                   # ็ฒพ็ตๅ›พ็‰‡
โ”‚   โ”œโ”€โ”€ tiles/                     # ็“ฆ็‰‡ๅ›พ็‰‡
โ”‚   โ”œโ”€โ”€ sound/                     # ้Ÿณ้ข‘ๆ–‡ไปถ
โ”‚   โ””โ”€โ”€ fonts/                     # ๅญ—ไฝ“ๆ–‡ไปถ
โ”œโ”€โ”€ config.json                    # ๆธธๆˆๅ‚ๆ•ฐ้…็ฝฎ
โ”œโ”€โ”€ docs/                          # ๆ–‡ๆกฃ
โ”‚   โ”œโ”€โ”€ README.md                  # ้กน็›ฎๆ–‡ๆกฃ
โ”‚   โ”œโ”€โ”€ tutorial.html              # ๆ•™็จ‹้กต้ข
โ”‚   โ”œโ”€โ”€ components.css             # Component styles
โ”‚   โ”œโ”€โ”€ dialogs.css                # Dialog styles
โ”‚   โ””โ”€โ”€ responsive.css             # Responsive styles
โ”œโ”€โ”€ assets/                        # Static assets
โ”‚   โ”œโ”€โ”€ maps/                      # Map data (easy/hard)
โ”‚   โ”œโ”€โ”€ backgrounds/               # Background images
โ”‚   โ”œโ”€โ”€ sprites/                   # Sprites
โ”‚   โ”œโ”€โ”€ tiles/                     # Tiles
โ”‚   โ”œโ”€โ”€ sound/                     # Audio files
โ”‚   โ””โ”€โ”€ fonts/                     # Fonts
โ”œโ”€โ”€ config.json                    # Game configuration
โ”œโ”€โ”€ docs/                          # Documentation (see below)
โ”‚   โ”œโ”€โ”€ README.md                  # Detailed docs
โ”‚   โ”œโ”€โ”€ tutorial.html              # Tutorial
โ”‚   โ”œโ”€โ”€ credits.html               # Credits
โ”œโ”€โ”€ index.html                     # Main entry point
โ”œโ”€โ”€ package.json                   # Project config
โ””โ”€โ”€ ReadMe.md                      # This file

๐ŸŽฎ Game Features

Core Gameplay

  • Intelligent Bunny AI: A* pathfinding
  • Strategic Play: Place blockers to prevent the bunny from escaping
  • Multiple Levels: 30 easy + 30 hard maps
  • Real-time Feedback: Dynamic path visualization

Technical Features

  • Pure JavaScript: No external dependencies required
  • Modular Architecture: Easy to maintain and extend
  • Responsive Design: Adapts to all screen sizes
  • Modern UI: Smooth animations and user-friendly interface

๐Ÿ› ๏ธ Developer Guide

Architecture Overview

Core Modules (src/core/)

  • GameController: Main game controller, coordinates systems
  • GameEngine: Game logic engine
  • UIManager: UI management
  • EventHandler: Global event management

Managers (src/managers/)

  • GameInitializer: Game initialization
  • ConfigManager: Centralized configuration
  • AudioManager: Music and sound
  • DialogManager: Dialogs and popups

Services (src/services/)

  • Bunny: AI and pathfinding
  • MapService: Map data and logic
  • BlockerService: Blocker management
  • DocumentationService: Documentation loading

๐Ÿ“Š Technology Stack

Frontend

  • JavaScript ES6+ - Modern JavaScript
  • Canvas API - 2D rendering
  • ES6 Modules - Modular development
  • CSS3 - Modern styles and animation

Algorithms

  • A* Algorithm - Pathfinding
  • Graph Theory - Map and blocker logic
  • State Machine - Game state management

๐ŸŽจ Game Interface

Main UI

  • Game Canvas: 900x600px play area
  • Info Panel: Game state and controls
  • Map Controls: Difficulty and map selection
  • Game Controls: Start, pause, stop

Dialog System

  • Tutorial Dialog: Gameplay instructions
  • About Dialog: Game info
  • Credits Dialog: Developer info
  • License Dialog: Terms of use

๐Ÿ› Troubleshooting

Common Issues

  • Game does not start: Check browser console for JavaScript errors; verify resource paths and module imports.
  • Audio does not play: Most browsers require user interaction before playing audio. Click the game area first.
  • Map loading fails: Ensure assets/maps/ exists and JSON files are valid.

Debug Tools

In the browser console:

tutorialCommands.status()   // Check tutorial status
tutorialCommands.restart()  // Restart tutorial
tutorialCommands.help()     // Show help

๐Ÿ“ Development Guidelines

Code Style

  • Use ES6+ syntax
  • Modular development
  • Clear comments and documentation
  • Consistent naming conventions

File Organization

  • Group by feature/folder
  • Keep structure clear
  • Avoid circular dependencies

๐Ÿ“„ License

GPL3 - see LICENSE

โค๏ธ Special Thanks

Some images are generated using AI technology. Some code is written with the assistance of AI programming tools.

For open source and media attributions, see docs/credits.html.

๐Ÿค Contributing

Contributions are welcome! Please open issues or pull requests.

๐Ÿ“š Documentation

For more details, see the docs/ folder, including docs/README.md and docs/tutorial.html.


๐ŸŽ‰ Enjoy the game!