8000 GitHub - bsagevedant/sage-balloon: fun
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

bsagevedant/sage-balloon

Repository files navigation

Balloon Shooting Game

An engaging endless balloon shooting game with multiple mechanics, scoring systems, and performance optimizations. Screenshot 2025-03-16 at 7 01 32โ€ฏPM

๐ŸŽฎ Core Game Mechanics

๐ŸŽˆ Balloon System

  • Multiple Balloon Types: Solid, striped, dotted.
  • Different Movement Patterns: Straight, zigzag, sine wave.
  • Behavior:
    • Continuous flow from bottom to top.
    • Auto-respawns when popped or reaches the top.
    • Random sizes (30-50px).
    • Random colors from a predefined palette.
    • Points based on size (smaller = more points).

๐Ÿ”ซ Shooting Mechanics

  • Click-to-shoot projectiles traveling upward.
  • Collision detection with balloons.
  • Red projectile visualization.
  • Custom crosshair following the mouse.

๐Ÿ† Scoring System

  • Base points per balloon.
  • Combo multiplier system.
  • High score tracking with localStorage.
  • Combo timeout (2 seconds).

โš™๏ธ Key Functions

createBalloon(yPos)

Creates new balloon objects.

  • Parameters: yPos (starting Y position).
  • Properties:
    • Random pattern, direction, size, color.
    • Calculated points.
    • Movement parameters (amplitude, frequency, phase).

drawBalloon(ctx, balloon)

Renders balloons with different patterns.

  • Patterns:
    • Solid: Single color fill.
    • Striped: Gradient effect.
    • Dotted: Base color with white dots.

gameLoop()

Main game loop handling:

  • Canvas clearing.
  • Balloon movement.
  • Projectile updates.
  • Collision detection.
  • Score updates.
  • Drawing all elements.

handleMouseMove(e)

  • Tracks mouse position.
  • Updates crosshair position.

handleClick(e)

  • Creates new projectiles.
  • Handles game restart.

๐ŸŽจ UI Elements

  • Score Display:
    • Current score.
    • Combo multiplier.
    • High score.
  • Visual Elements:
    • Custom crosshair.
    • Projectile trails.
    • Balloon patterns.
    • Background.

๐Ÿ› ๏ธ Technical Features

๐Ÿ“ Canvas Management

  • Responsive sizing.
  • Window resize handling.
  • Efficient clearing and redrawing.

๐Ÿ“Š State Management

  • Game state tracking.
  • Score persistence.
  • Balloon array management.
  • Projectile tracking.

๐Ÿš€ Performance Optimizations

  • requestAnimationFrame for smooth animation.
  • Efficient collision detection.
  • Automatic cleanup of off-screen projectiles.

๐Ÿ’พ Data Persistence

  • Local storage for high scores.
  • Session maintenance.

โšก Game Constants

const projectileSpeed = 10;
const balloonSpawnRate = 1000; // in ms
const maxBalloons = 15;
const comboTimeout = 2000; // in ms
const colorPalette = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEEAD', '#D4A5A5'];

๐Ÿ—๏ธ Interfaces

๐ŸŽˆ Balloon

interface Balloon {
  id: number;
  x: number;
  y: number;
  color: string;
  speed: number;
  size: number;
  points: number;
  pattern: 'solid' | 'striped' | 'dotted';
  direction: 'straight' | 'zigzag' | 'sine';
  amplitude?: number;
  frequency?: number;
  phase?: number;
}

๐Ÿ”ซ Projectile

interface Projectile {
  id: number;
  x: number;
  y: number;
  speed: number;
}

๐Ÿš€ How to Play

  1. Move the mouse to aim.
  2. Click to shoot projectiles.
  3. Pop balloons to earn points.
  4. Maintain combos for higher scores.
  5. Track your highest score!

๐Ÿ“œ License

This project is licensed under the MIT License.


Enjoy popping balloons and setting high scores! ๐ŸŽฏ๐ŸŽˆ

Releases

No releases published

Packages

No packages published
0