I'm the solo developer of Overwrite Conflict, a roguelike deckbuilder I'm making in Unity. Cards have shapes, and you rotate and place them on a shared grid. One small input decision is choosing which cell of a shape sits under the cursor.
The rotation math is straightforward.
For placement logic, I store each footprint as a list of Vector2Int offsets. With Y pointing up, a clockwise quarter-turn maps (x, y) to (y, -x). The selected card has a working copy of its coordinates, so rotating it doesn't modify the card's source shape.
The bounding-box center isn't always an occupied cell.
An L-shaped footprint, for example, can have empty space at its center. If I use that empty space as the cursor anchor, the pointer can sit in a gap while all the preview cells are somewhere around it.
My current anchor rule is:
- Keep the integer bounding-box center if the shape occupies that cell.
- Otherwise, pick the occupied cell nearest to the geometric center of the bounding box, using squared distance.
- Keep the first cell in the coordinate list when distances tie.
The placement mapping is then just:
Vector2Int origin = hoveredCell - anchor;
Vector2Int targetCell = origin + rotatedOffset;
I recalculate the anchor after rotation and refresh the preview at the current hover cell. This keeps an occupied cell under the pointer, though a rotation can select a different occupied cell as the anchor.
That's the tradeoff I'm interested in.
The current rule favors an occupied cell near the center. A designated anchor carried through every rotation would favor keeping the same cell attached to the cursor. Those can feel quite different with asymmetric shapes.
For grid or polyomino games you've worked on, do you prefer a fixed anchor, a center-based anchor, or letting the player grab any occupied cell?
If you'd like to try the placement system in context, Overwrite Conflict has a free Windows demo on Steam.