Grouping Points Together in Shapes
Explore how to create a Shape module that groups points into pentomino shapes with specific colors and attributes. Understand how to implement a constructor that applies transformations to points for accurate rendering, helping you build the core game logic in Phoenix LiveView.
We'll cover the following...
The Shape module is responsible for modeling pentomino shapes. It will wrap up the attributes that describe a shape and implement some functions that manage the behavior of shapes. In this lesson, we’ll define the Shape module and implement its constructor function. We’ll use the Point.prepare/4 function we just built to prepare a shape for rendering in the correct location, given some input.
Representing Shape attributes
Let’s begin with the attributes that describe a shape. Each shape will have a distinct color and a list of points. The Shape module will wrap up ...