Tracking a Game in a Board
Explore how to build a game board core module by defining board structs and attributes in Phoenix LiveView. Learn to create constructors for new boards, manage pentomino shapes, and understand board interactions like selecting, moving, and placing pieces. This lesson sets the foundation for tracking and updating the game state effectively.
The Board module will be responsible for tracking a game. It will produce structs that describe the attributes of a board and implement a constructor function for creating new boards when a user starts a game of Pentominoes. Later, it will implement reducers to manage the behavior of a board, including commands to select a pento to move, rotate, or reflect a pento, drop a piece into place, and more.
Representing board attributes
A board struct will have the following attributes:
points: The points that make up the shape of the empty board that the user will fill up with pentominoes. All of our shapes will be rectangles of different sizes.completed_pentos: The list of pentominoes that the user has placed on the board.palette: The provided pentominoes that the user has available to solve the puzzle.active_pento: The currently selected pentomino that the user is moving around the board.
We start by defining our module, ...