Skip to content

mgrinstein/BATS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ BATS: Bricks Astronaut Training Simulator ๐ŸŽƒ

A browser-based game that simulates astronaut dexterity tasks in microgravity using LEGO bricks. Built with Vite and vanilla JavaScript.

BATS Game Screenshot

๐ŸŽฎ Features

  • Drag-and-Drop LEGO Bricks: Five colorful LEGO-style bricks with realistic studs
  • Gravity Control: Toggle between Microgravity (drift mode) and Supergravity (stable mode)
  • Goal Area: Highlighted drop zone where bricks must be placed
  • Microgravity Physics: Bricks drift and wobble realistically when moved
  • Real-Time Scoreboard: Track elapsed time and errors
  • Completion Detection: "MISSION COMPLETE!" message when all bricks are placed
  • Space Theme: Gradient space background with stars
  • Halloween Elements: Animated bats with fluttering wings ๐Ÿฆ‡

๐Ÿš€ Quick Start

Prerequisites

  • Node.js (v14 or higher)
  • npm

Installation

# Clone the repository
git clone https://github.com/mgrinstein/BATS.git
cd BATS

# Install dependencies
npm install

Development

# Run development server
npm run dev

# Open browser to http://localhost:5173

Production Build

# Build for production
npm run build

# Preview production build
npm run preview

๐ŸŽฏ How to Play

  1. Choose Gravity: Select your preferred gravity setting

    • ๐ŸŒ™ Microgravity (Drift): Challenging mode with realistic drift
    • ๐ŸŒ Supergravity (Stable): Easy mode with precise control
  2. Drag Bricks: Click and drag LEGO bricks from the left side

  3. Place in Goal: Move bricks into the green GOAL ZONE on the right

  4. Avoid Errors: Keep bricks inside the canvas (dropping them outside counts as an error)

  5. Complete Mission: Place all 5 bricks in the goal zone to win!

๐Ÿ—๏ธ Project Structure

BATS/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ Brick.js        # Brick class with physics and rendering
โ”‚   โ”œโ”€โ”€ Game.js         # Game state management and game loop
โ”‚   โ”œโ”€โ”€ main.js         # Application entry point and UI setup
โ”‚   โ””โ”€โ”€ style.css       # Space-themed styling
โ”œโ”€โ”€ public/             # Static assets
โ”œโ”€โ”€ index.html          # HTML template
โ””โ”€โ”€ package.json        # Project configuration

๐Ÿ› ๏ธ Technical Details

Architecture

  • Modular Design: Separate classes for Brick and Game logic
  • Canvas Rendering: 60 FPS game loop using requestAnimationFrame
  • Physics Simulation: Velocity-based drift for microgravity effect
  • Event-Driven: Mouse events for intuitive drag-and-drop

Key Components

Brick Class (src/Brick.js)

  • Drag-and-drop functionality
  • Microgravity drift physics
  • LEGO-style rendering with studs
  • Collision detection

Game Class (src/Game.js)

  • Game state management
  • Canvas rendering
  • Goal area detection
  • Scoreboard updates
  • Completion checking

๐ŸŽจ Customization

Adding More Bricks

Edit src/Game.js in the initBricks() method:

const colors = ['#ff0000', '#0000ff', '#ffff00', '#00ff00', '#ff6600', '#ff00ff'];

Adjusting Gravity

Modify the drift effect in src/Brick.js:

// Increase drift
this.x += (targetX - this.x) * 0.05 + driftX;  // Lower multiplier = more drift

// Decrease drift
this.x += (targetX - this.x) * 0.2 + driftX;   // Higher multiplier = less drift

Changing Goal Area Size

Edit src/Game.js in the constructor:

this.goalArea = {
  x: canvas.width - 250,
  y: canvas.height - 200,
  width: 200,   // Adjust width
  height: 150   // Adjust height
};

๐Ÿงช Testing

The game has been tested for:

  • โœ… Drag-and-drop functionality
  • โœ… Gravity mode switching
  • โœ… Goal detection
  • โœ… Scoreboard updates
  • โœ… Completion message
  • โœ… Browser compatibility
  • โœ… Build process
  • โœ… Security (CodeQL: 0 vulnerabilities)

๐Ÿ”’ Security

This project has been scanned with CodeQL and contains zero security vulnerabilities.

๐Ÿ“ License

This project is available for educational and demonstration purposes.

๐Ÿค Contributing

Contributions are welcome! This is a minimal implementation designed for extensibility.

Future Enhancement Ideas

  • Add more brick shapes and sizes
  • Implement time limits and scoring
  • Add difficulty levels
  • Include sound effects
  • Add mobile touch support
  • Create multiple missions/levels
  • Add multiplayer mode
  • Include leaderboards

๐Ÿ™ Acknowledgments

  • Built with Vite
  • Inspired by real astronaut training simulators
  • Halloween theme for October 31st ๐ŸŽƒ

๐Ÿ“ง Contact

For questions or suggestions, please open an issue on GitHub.


Made with โค๏ธ for astronaut training and LEGO enthusiasts

About

Bricks Astronaut Training Simulator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published