Skip to content
artemnovichkovPublic

About

Flappy Bird for the foldable iPhone Duo: snap the hinge open to flap. SwiftUI, onHingeChange, Canvas.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

DuoBird icon

DuoBird

Flappy Bird for the foldable iPhone Duo. Snap the hinge open to flap.

iOS 27.1+ Xcode 27.1+ Swift 6 SwiftUI MIT License

duobird-autopilot-2.mp4

How to Play

Hold the iPhone Duo half open, like a book.

  • Snap the hinge open to flap. Each quick unfold is one flap.
  • Fold back a little to get ready for the next one.
  • Fly through the gaps between the pipes. Each pipe you pass is a point.

No hinge? Tap anywhere to flap.

How It Works

The hinge is the button. GameView listens to onHingeChange and feeds each angle to a FlapDetector:

.onHingeChange { _, newContext in
    guard let degrees = newContext.hinge?.angle.degrees else { return }
    if flapDetector.update(degrees: degrees) {
        game.flap()
    }
}

The detector tracks the lowest angle since the last flap. When the hinge opens 10° past it, that's a flap. Then it waits until the hinge folds back 5°, so one long unfold is still one flap. You don't need to open the device fully, and you don't need to slam it.

Gentler physics. Snapping a hinge is slower than tapping a screen, so gravity is lower and the gaps are wider than in the original. The gap also grows with the screen height.

Everything is drawn in a Canvas. Scenery draws the sky, parallax clouds and hills, pipes, and ground. drawBird draws the bird. A TimelineView(.animation) steps Game every frame.

Requirements

  • Xcode 27.1+
  • iOS 27.1+ SDK
  • iPhone Duo simulator or device for the hinge. On other devices, tap to flap.

Building

xcodebuild -project DuoBird.xcodeproj -scheme DuoBird \
  -destination 'platform=iOS Simulator,name=iPhone Duo' build

In the simulator, move the hinge from the command line with hinge.

Project Structure

DuoBird
├── App          # App entry point, game screen, and overlays
├── Game         # Rules and physics, flap detector, drawing
└── Resources    # Asset catalog

The Xcode project uses Xcode's JSON project format (project.xcproj). Each source file is listed there with its target membership.

Inspiration

Foldy Bird by @rebane2001, a Flappy Bird clone for Android foldables that you play with the hinge.

For more iPhone Duo APIs, see iPhone Duo by Examples.

Author

Artem Novichkov, https://artemnovichkov.com/

License

The project is available under the MIT license. See the LICENSE file for more info.

About

Flappy Bird for the foldable iPhone Duo: snap the hinge open to flap. SwiftUI, onHingeChange, Canvas.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages