Atelier Clockwork

Hexagons On Screen

Behind Schedule, but Moving

After several months of almost zero activity on the game, I now have drawing code in place. After learning a lot about how collection view layouts work, how to animate them, and how to make them smoothly inter-operate with gestures.

The layout itself is dead simple, cell size is dictated by a radius, and after that, the values for almost all of the cells only need to be calculated once. The shorter dimension of the hexagon is a bit trickier to calculate, as it's not 2 * radius but rather it's 2 * (radius * sin(M_PI / 3)) as that's calculating the x coordinate for 60° offset from the tip of the hexagon. After that, every other row is offset by half of that value horizontally. The vertical offset for each row is calculated in a similar manner.

To add moving objects on top of the grid, I've added supplementary views. This will allow the moving objects to not require any changes to the static base cells in the collection and should attach cleanly to the gesture recognizer hat I'll be using for player movement and the like.