Skip to content

ncercos/FlappyBird-Clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Flappy Bird (Clone)

Flappy Bird (Clone) is a faithful Java recreation of the classic, where players tap to keep their bird airborne, navigating it through a series of challenging pipes. One wrong move means a crash, so timing is key! Rack up high scores to earn medals and push yourself to beat your personal best in this addictive, retro-style game.

Daytime Menu Nighttime Menu

🎮 How to Play

Objective: Guide your bird through pipes by keeping it airborne. Each successful pipe passage earns a point, with medals awarded at score milestones.

  • SPACE/Left Mouse Button - Jump
  • C - Toggle Day/Night
  • B - Change Bird Color  

⚙️ Technologies Used

  • Java SDK 22: Core programming language and development kit
  • Swing/AWT: Used for GUI components and graphics rendering
  • Custom Game Engine: Built from scratch with game state management
  • Thread-based Game Loop: Maintains consistent 60 FPS gameplay
  • BufferedImage: Handles sprite loading and image manipulation

✨Key Features

1. Game Loop System

Maintains smooth 60 FPS gameplay with precise timing and frame management.
 

How it works: A dedicated thread continuously updates game state and renders frames at consistent intervals.

@Override  
public void run() {  
  double timePerFrame = 1000000000.0 / 60;  
  long lastFrame = System.nanoTime();  
  long now;  
  
  while(true) {  
	  now = System.nanoTime();  
	  if(now - lastFrame >= timePerFrame) {  
		  update();  
		  repaint();  
		  lastFrame = now;  
	  } 
    }
 }

2. Smooth Graphics Rendering

Double-buffered rendering system prevents screen tearing and ensures fluid animation.
 

How it works: Draws game elements to an off-screen buffer before displaying them on screen.

@Override  
protected void paintComponent(Graphics g) {  
 if(scene == null) {  
	 scene = createImage(GAME_WIDTH, GAME_HEIGHT);  
	 pen = scene.getGraphics();  
 }  
 pen.clearRect(0, 0, GAME_WIDTH, GAME_HEIGHT);  
 if(getCurrentState() != null) getCurrentState().draw(pen);  
 g.drawImage(scene, 0, 0, this);  
}

3. Precise Collision Detection

Accurate hitbox-based collision system for interactions between bird and obstacles.
 

How it works: Uses rectangle-based hitboxes with precise overlap detection.

public boolean overlaps(Hitbox hb) {  
  return (x <= hb.x + hb.width)  &&  
         (x + width >= hb.x)     &&  
         (y <= hb.y + hb.height) &&  
         (y + height >= hb.y);  
}

4. Realistic Physics System

Smooth gravity-based movement with responsive jump mechanics.
 

How it works: Implements physics calculations for bird movement with configurable parameters.

public void move() {  
  if(dead)return;  
  vy += GRAVITY;  
  y += vy;  
  y = Math.max(y, 0);  
  // ...death logic...
}

5. Dynamic Bird Colors

Randomized bird colors with smooth animation system.
 

How it works: Randomly selects between yellow, red, or blue bird sprites with fluid wing animations every round!

private String getBirdColor() {  
  switch (ThreadLocalRandom.current().nextInt(3) + 1) {  
  default -> { return "yellow"; }  
  case 2 -> { return "red"; }  
  case 3 -> { return "blue"; }  
  }
}

Different Bird Colors

6. Medal System

Tiered achievement system that rewards player skill. Awarded on scores of 10+, 20+, 30+, and 40+ points, respectively.
 

How it works: Awards increasingly valuable medals based on score thresholds, with visual feedback.

public enum Medal {  
  
 BRONZE, SILVER, GOLD, PLATINUM;  
  
 private final int minimumScore;  
  
 Medal() {    
  minimumScore = (ordinal() + 1) * 10;  
 }  

public static Medal getMedal(int score) {  
 Medal medal = null;  
 for(Medal m : values()) {  
  if(score >= m.getMinimumScore())  
	  medal = m;  
 }  
 return medal;  
}  

Score Medal Types



⚠️ Disclaimer

Graphical and auditory assets used in this clone are owned by DOTGEARS (.GEARS) Studios © 2011 - 2024.
This project is created for educational and entertainment purposes only & has no affiliation with the original game.

About

A Java game where players tap to keep their bird airborne, navigate pipes, and earn medals. Timing is crucial!

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages