The code containing the definitions and declarations sections is shown as follows:
typedef struct Bounds {
int width;
int height;
} Bounds;
// We're using the term "Rect" to represent the rectangle the
// image occupies:
typedef struct Rect {
int x;
int y;
int width;
int height;
// Horizontal direction of travel (L/R):
char horizDir;
// Vertical direction of travel (U/D):
char vertDir;
} Rect;
struct Bounds bounds;
struct Rect rect;
New properties were added to the existing Rect definition to accommodate for flexible sizing and tracking movement in the x and y directions. We defined a new struct, Bounds, and removed the existing #define statements because the <canvas> element is no longer a square with static dimensions. A new instance of both elements is declared when the module loads. The dimensional properties of these instances are assigned in the start() function, which we'll cover next.