Skip to content

ProneilS/flappyBird

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flappy Bird - JavaScript Learning Project

A simple, well-documented implementation of the classic Flappy Bird game using HTML5 Canvas and vanilla JavaScript. This project is designed for learning game development concepts and JavaScript programming.

🎮 How to Play

  • Objective: Navigate the yellow bird through gaps between green pipes
  • Controls:
    • Press SPACEBAR or CLICK anywhere on the game area to make the bird flap
    • Same controls work for starting the game and restarting after game over
  • Scoring: Gain 1 point for each pair of pipes you successfully pass through
  • Game Over: Touching pipes, ground, or ceiling ends the game

🚀 Getting Started

  1. Download the files: Get all three files (index.html, app.js, style.css)
  2. Open the game: Simply open index.html in any modern web browser
  3. Start playing: Press spacebar or click to begin!

No installation, setup, or external dependencies required - just open and play!

📁 Project Structure

flappy-bird/
├── index.html    # Main HTML file with game canvas and UI
├── app.js        # Game logic and JavaScript code
├── style.css     # Styling and visual design
└── README.md     # This documentation file

🛠️ Technical Features

Game Mechanics

  • Physics: Realistic gravity simulation with customizable jump strength
  • Collision Detection: Precise boundary checking for bird-pipe interactions
  • Procedural Generation: Infinite pipe generation with random gap positions
  • Game States: Menu, playing, and game over states with smooth transitions
  • Score System: Real-time score tracking and display

Code Quality

  • Heavily Commented: Every function and concept explained for learning
  • Modular Design: Clean separation of game logic, rendering, and input handling
  • Constants: Easy-to-modify game parameters for customization
  • Best Practices: Modern JavaScript with clear variable naming and structure

Visual Design

  • Canvas Graphics: All graphics drawn programmatically - no external images needed
  • Smooth Animation: 60 FPS game loop using requestAnimationFrame
  • Responsive Design: Centered layout that works on different screen sizes
  • Visual Polish: Gradients, shadows, and clean typography

🎨 Customization Options

The game is designed to be easily customizable. Here are some parameters you can modify in app.js:

// Physics Constants
const GRAVITY = 0.6;        // Bird falling speed
const JUMP_STRENGTH = -10;  // Bird flapping power
const PIPE_SPEED = 2;       // Pipe movement speed
const PIPE_GAP = 180;       // Gap size between pipes
const PIPE_WIDTH = 50;      // Width of pipes

Easy Modifications

  • Difficulty: Increase gravity or decrease pipe gap
  • Speed: Adjust pipe speed for faster/slower gameplay
  • Colors: Change colors in the drawing functions
  • Bird Size: Modify the bird radius
  • Game Area: Adjust canvas dimensions in HTML

📚 Learning Outcomes

This project demonstrates several important programming concepts:

JavaScript Concepts

  • Object-Oriented Programming: Game objects with properties and methods
  • Event Handling: Keyboard and mouse input processing
  • Animation Loops: Game loop architecture with requestAnimationFrame
  • Array Manipulation: Dynamic pipe management
  • Collision Detection: Mathematical boundary checking
  • State Management: Game state transitions

Game Development Concepts

  • Game Loop: Update → Check Collisions → Render cycle
  • Entity Management: Creating, updating, and destroying game objects
  • Input Handling: Responsive controls for gameplay
  • Scoring Systems: Point tracking and display
  • Physics Simulation: Gravity and movement calculations

Web Development

  • HTML5 Canvas: 2D graphics rendering
  • CSS Layout: Responsive design and styling
  • DOM Manipulation: Updating UI elements
  • File Organization: Proper project structure

🔧 Browser Compatibility

Works in all modern browsers including:

  • Chrome 50+
  • Firefox 45+
  • Safari 10+
  • Edge 12+

📖 Code Documentation

Every function in the code includes detailed comments explaining:

  • Purpose: What the function does
  • Parameters: Input values and their meanings
  • Logic: Step-by-step explanation of the algorithm
  • Game Development Concepts: Why certain approaches are used

🎯 Future Enhancement Ideas

Want to extend the project? Here are some ideas:

  • Add sound effects and background music
  • Implement different bird characters or power-ups
  • Create multiple difficulty levels
  • Add particle effects for flapping or collisions
  • Implement local high score storage
  • Add mobile touch controls
  • Create animated pipe textures
  • Add day/night cycle backgrounds

🤝 Contributing

This is a learning project! Feel free to:

  • Fork and modify for your own learning
  • Add new features and improvements
  • Share with other learners
  • Use as a starting point for more complex games

📝 License

This project is created for educational purposes. Feel free to use, modify, and share!


Happy Coding! 🚀

This project demonstrates that you can create engaging games with just vanilla JavaScript - no frameworks required!

About

Classic Flappy Bird Game

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published