Atelier Clockwork

Building a Board

Now that the game logic is in place, I'm ready to build a game board. Since there's a new layout system to work with, I'm going to use a Grid. The first thing that I need to do is to make an Identifiable type that stores a row worth of grid cells, and expose it in the GameService:

More

Adding the missing part

One of the "missing" features in SwiftUI that's tripped me up since the first version of Minesweeper that I implemented is that due to the cross platform nature of SwiftUI, there's no concept of a "right click", in previous version I've worked around that by supporting an option click recognizer for the touch gesture recognizer, but that isn't ideal for the macOS implementation.

As far as I can tell, there's still no right click support natively in SwiftUI, so I decided to hack something together myself. I decided that it should support:

More

Making up the rules as we go along

I've done enough UI development to be able to test out the rules, but I'm going to just ignore that for now. Since I've built Minesweeper a handful of times now, I had a decent place to start from. This requires:

  • A GridPoint struct to allow for addressing points on the grid
  • A Game struct that tracks all of the game state and allows the gameplay actions
  • Enums that report the state of the game (active, win, lose), and the possible states that each grid point can occupy.

More

Shall we make a game?

One of my first things I built when learning SwiftUI was an implementation of Minesweeper. I've done a major refactor of the game every year as more SwiftUI features have been added, and I've learned more about working in SwiftUI.

I'm starting the process again this year, and as I complete the implementation I'll write blog posts covering any interesting points that I've learned.

My goal for features this year is:

More

Testing out some of the new toys

On the long list of interesting new things to check out from WWDC this year, the first one that I wanted to take a look at was the new NavigationStack, as the limitations in the previous NavigationView led to my previous project using UIKit to back navigation in a SwiftUI first project.

More