Skip to content

Smile to jump! ๐Ÿ˜Š A unique Flappy Bird twist using your webcam and facial expressions to control gameplay. Powered by React and face-api.js.

License

Notifications You must be signed in to change notification settings

nhannpl/Happy-Flappy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ˜Š Happy Flappy

A unique twist on the classic Flappy Bird game that uses facial emotion detection to control gameplay! Smile to jump higher, and watch out - sadness increases gravity!

Live Demo

๐ŸŽฎ Game Features

  • Emotion-Controlled Gameplay: Your facial expressions control the bird
    • Happy/Smile: Jump power increases based on your smile intensity
    • Sadness: Gravity increases, making the bird fall faster
  • Real-time Face Detection: Uses TensorFlow.js and face-api.js for instant emotion recognition
  • Adjustable Difficulty: Control pipe speed from 10-30 for varying difficulty levels
  • Visual Feedback: Live emotion meters show your current happiness and sadness levels
  • Webcam Integration: Your webcam feed becomes the game background

๐Ÿš€ How to Play

  1. Allow camera access when prompted
  2. Smile to charge your jump power (shown on the Jump Power meter)
  3. Click or tap to make the bird jump - jump height is based on your smile!
  4. Avoid pipes and try to set a high score
  5. Don't be sad - sadness increases gravity and makes the game harder!

๐Ÿ› ๏ธ Technologies Used

  • React 19 - Frontend framework
  • face-api.js - Face detection and emotion recognition
  • TensorFlow.js - Machine learning models
  • HTML5 Canvas - Game rendering
  • Webcam API - Real-time video capture

๐Ÿ“ฆ Installation

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn
  • Webcam/camera access

Setup

  1. Clone the repository:
git clone https://github.com/nhannpl/Happy-Flappy.git
cd Happy-Flappy
  1. Install dependencies:
npm install
  1. Start the development server:
npm start
  1. Open http://localhost:3000 in your browser

๐Ÿ—๏ธ Build for Production

npm run build

The optimized production build will be in the build/ folder.

๐ŸŒ Deploy to GitHub Pages

npm run deploy

๐Ÿ“ Project Structure

Happy-Flappy/
โ”œโ”€โ”€ public/
โ”‚   โ””โ”€โ”€ models/          # TensorFlow.js face detection models
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ Bird.js           # Bird component
โ”‚   โ”‚   โ”œโ”€โ”€ Pipes.js          # Pipe obstacles
โ”‚   โ”‚   โ”œโ”€โ”€ EmotionMeters.js  # Visual feedback for emotions
โ”‚   โ”‚   โ””โ”€โ”€ GameOverlay.js    # Start/Game Over screen
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”‚   โ”œโ”€โ”€ useFaceDetection.js  # Face detection logic
โ”‚   โ”‚   โ””โ”€โ”€ useGameLoop.js       # Game physics and collision
โ”‚   โ”œโ”€โ”€ App.js           # Main game component
โ”‚   โ””โ”€โ”€ constants.json   # Game configuration
โ””โ”€โ”€ package.json

๐ŸŽฏ Game Mechanics

  • Jump Power: Based on happiness/smile detection (0-100%)
  • Gravity: Increases with sadness detection
  • Collision Detection: Accurate hitboxes for pipes and screen boundaries
  • Score System: Points awarded for successfully passing pipes
  • Screen Shake: Visual feedback on collisions

๐Ÿค Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

๐Ÿ“ License

This project is MIT licensed.

๐Ÿ‘ค Author

Nhan

๐Ÿ™ Acknowledgments

  • Inspired by the classic Flappy Bird game
  • Built with face-api.js by Vincent Mรผhler
  • TensorFlow.js models for emotion detection

Note: This game requires camera access to function. Your webcam feed is processed locally in your browser and is never uploaded or stored anywhere.

About

Smile to jump! ๐Ÿ˜Š A unique Flappy Bird twist using your webcam and facial expressions to control gameplay. Powered by React and face-api.js.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published