A simple Flappy Bird clone built using Java and Java Swing. This project was created to practice Object-Oriented Programming (OOP), Java GUI development, game loops, collision detection, and event handling.
Add screenshots or GIF here
| Main Menu | Gameplay |
|---|---|
![]() |
![]() |
Or
- Overview
- Features
- Technologies Used
- Project Structure
- How It Works
- Installation
- Running the Project
- Controls
- Game Mechanics
- OOP Concepts Used
- Future Improvements
- Learning Outcomes
- Known Issues
- Contributing
- License
- Author
Java Flappy Bird is a desktop game inspired by the classic Flappy Bird.
The objective is simple:
- Control the bird
- Avoid hitting pipes
- Try to achieve the highest score possible
This project focuses on implementing game development fundamentals using pure Java without external game engines.
- Bird movement with gravity
- Jump mechanics
- Random pipe generation
- Collision detection
- Score system
- Game Over screen
- Restart game
- Smooth animation using game loop
- Keyboard controls
- Simple pixel-style gameplay
- Java
- Java Swing
- Java AWT
- OOP (Object-Oriented Programming)
No external libraries are required.
Example:
java-flappy-bird
โ
โโโ src
โ โโโ Main.java
โ โโโ GamePanel.java
โ โโโ Bird.java
โ โโโ Pipe.java
โ โโโ Game.java
โ โโโ assets
โ โโโ bird.png
โ โโโ pipe.png
โ โโโ background.png
โ
โโโ images
โ
โโโ README.md
โ
โโโ LICENSE
Your structure may be different depending on your project.
The game continuously performs these steps:
Start Game
โ
Initialize Bird
โ
Generate Pipes
โ
Game Loop
โ
Update Bird Position
โ
Move Pipes
โ
Check Collision
โ
Increase Score
โ
Render Graphics
โ
Repeat Until Game Over
The game loop is responsible for:
- Updating object positions
- Detecting collisions
- Redrawing the screen
- Maintaining FPS
git clone https://github.com/gangsarrz/java-flappy-bird.gitOpen using
- IntelliJ IDEA
- Eclipse
- NetBeans
- VS Code (Java Extension Pack)
javac *.javaor using your IDE.
Run:
java Mainor simply click Run inside your IDE.
| Key | Action |
|---|---|
| Space | Jump |
| R | Restart Game (optional) |
| ESC | Exit (optional) |
The bird constantly falls due to gravity.
velocity += gravity
position += velocity
When the player presses Space:
velocity = jumpForce
The bird moves upward.
Pipes are generated at random heights with a fixed gap between the top and bottom pipes.
Example:
Pipe
โโโโโ
Gap
โโโโโ
The game checks collision between:
- Bird vs Top Pipe
- Bird vs Bottom Pipe
- Bird vs Ground
- Bird vs Ceiling
If a collision occurs:
Game Over
The score increases every time the bird successfully passes a pipe.
Example:
Bird
โ
Pipe
โ Score +1
This project demonstrates several OOP principles.
Each game object manages its own data.
Example:
- Bird
- Pipe
Game logic is separated into different classes.
Can be extended for future entities.
Useful when adding enemies or collectibles.
Through this project, I learned about:
- Java Swing
- Java Graphics
- Event Handling
- Keyboard Listener
- Timers
- Animation
- Collision Detection
- Random Generation
- Object-Oriented Programming
- Game Development Basics
- Code Organization
- Debugging Java Applications
Planned features:
- Sound effects
- Background music
- High score saving
- Difficulty levels
- Pause menu
- Animated bird
- Better graphics
- Mobile version
- Power-ups
- Multiple bird skins
- Window resizing is not supported.
- Score resets after restarting.
- No save/load system.
- Basic collision detection.
Contributions are welcome.
If you'd like to improve this project:
-
Fork the repository
-
Create a new branch
git checkout -b feature/new-feature- Commit changes
git commit -m "Add new feature"- Push
git push origin feature/new-feature- Open a Pull Request
If you found this project helpful, consider giving it a โญ on GitHub.
It motivates me to build more open-source projects and continue learning.


