💡 Inspiration

When Apple announced iPhone Duo, its first foldable iPhone, one thing stood out to me: the hinge isn't just hardware, it's a new kind of input. Most apps will treat the fold as a layout problem. I wanted to treat it as a game mechanic.

I grew up playing hidden-grid battle games with friends, and the hardest part was always the same: how do you share one device when neither player can see the other's board? Passing a phone around meant someone always caught a glimpse.

Then it clicked: closing a foldable phone is the perfect privacy shield. What if folding the phone fired your missile and handed the device to your rival at the same time? That idea became FoldWars.

🛠️ How I built it

FoldWars is a native iOS app built with Swift 6 and SwiftUI, using the new iPhone Duo APIs in the iOS 27.1 SDK.

  • Hinge as the trigger: SwiftUI's onHingeChange modifier reports the hinge status (.closed, .partiallyOpen, .fullyOpen) and its angle. When the active player folds the phone, the missile launches and the game moves into a neutral handoff screen.
  • A privacy-first state machine: every transition between players goes through a .handoff state, so no fleet is ever on screen while the other player might be looking. The board is also hidden whenever the app goes to the background, so it never appears in the App Switcher.
  • Adaptive layouts: on the inner display, ArrangementView places the targeting grid and your own fleet side by side, split exactly on the fold. When the phone is partially folded, I read the fold's position through reserved regions so no grid cell is ever drawn across the crease. The outer display shows one board at a time.
  • Rotation handoff: as an alternative to folding, CoreMotion detects when the phone is turned toward the other player. For a phone lying flat, a handoff triggers when the yaw changes by at least 150° from the reference captured at the start of the turn, and holds for 300 ms:

$$ |\psi_{\text{now}} - \psi_{\text{ref}}| \geq 150^\circ \quad \text{for } \Delta t \geq 300\,\text{ms} $$

  • Art pipeline: I designed a five-ship space fleet (Scout, Fighter, Cruiser, Destroyer and Mothership) and generated the 3D-style art with an image model, writing detailed prompts to keep the camera, lighting and materials consistent across every asset.

📚 What I learned

  • Design for space, not devices. Apple's guidance for iPhone Duo is to stop checking screen sizes and orientations and adapt to the space available instead, using size classes and container geometry. It made the app work on regular iPhones and iPads almost for free.
  • Use the hinge for interaction, not layout. The hinge angle is great for effects and triggers, but layout should come from reserved regions and arrangements, which the system keeps accurate for every pose.
  • Perspective is math. To place ships and missiles on my one-point-perspective grid, I had to think like a camera. An object of real size $S$ at depth $z$ appears on screen with size

$$ s = \frac{f \cdot S}{z} $$

where $f$ is the focal length. That's why the Mothership, $2.5\times$ as long as the Scout on the grid $\left(\frac{5}{2} = 2.5\right)$, can still look huge while it sits near the vanishing point.

🧗 Challenges

  • Brand-new APIs. The iPhone Duo SDK had only just shipped, with little documentation and few examples. Some APIs behaved differently than early talks suggested, so I verified everything against the SDK headers and the iPhone Duo simulator.
  • Keeping secrets on a shared screen. Hidden information is the heart of the game, and it's surprisingly easy to leak: a frame during an animation, a snapshot in the App Switcher, a relaunch that restores the wrong board. Routing every change through a single handoff state was the fix.
  • Only one screen at a time. My first idea was one player on the inner display and one on the outer display. But apps can only show content on both displays at once in specific cases, like camera accessories, so I redesigned the game around turn-based handoffs instead.
  • Consistent AI-generated art. Getting an image model to respect an exact camera angle was hard. Ships drifted to the wrong perspective, and missiles showed the wrong side. I learned to describe the camera precisely (horizon height, vanishing point, field of view) and to use finished assets as references for new ones.

🚀 What's next

Online multiplayer, new battle arenas, power-ups like radar sweeps, and hinge-driven animations that make every fold feel like opening a blast door.

Built With

  • bitrig
  • figma
  • googleflow
Share this project:

Updates

Submission history