Josh Hirschkorn
--:--:--
All projects

Dec 2024 · Jan 2025

Memorize: SwiftUI Memory Card Game

A card-matching game built through Stanford's CS193p, using MVVM and custom view modifiers.

  • Swift
  • SwiftUI
  • MVVM
  • Animations

A SwiftUI memory card game built while working through Stanford’s CS193p course, used as a vehicle for learning SwiftUI’s reactive model properly rather than just getting something on screen.

Game model

The core is a generic MemoryGame model that works with any card content type, handling matching logic, shuffling and game state. Keeping the model generic and free of UI concerns is what makes the view layer simple.

Architecture and views

The app follows MVVM, with EmojiMemoryGame as the view model exposing @Published properties so the UI updates automatically, and ObservedObject and StateObject handling the reactive bindings.

The view layer is built from small composable pieces: CardView for each card, a Cardify view modifier providing the card appearance and flip animation, Pie as a custom shape for countdown indicators, and AspectVGrid to arrange cards to fit whatever space is available.