We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Cell

Our maze is made up of little boxes in a grid. Each box we call a "Cell", and it has 4 potential walls. The way the maze works, is that we start in one cell, and we're allowed to move to an adjacent cell as long as there isn't a wall in the way.

Let's build a Cell class that holds all the data about an individual cell. It should know which walls it has, know where it exists on the canvas in x/y coordinates, and have access to the window so that it can draw itself.

Assignment

    • has_left_wall (starts as True)
    • has_right_wall (starts as True)
    • has_top_wall (starts as True)
    • has_bottom_wall (starts as True)
    • __x1 (starts as -1.0)
    • __x2 (starts as -1.0)
    • __y1 (starts as -1.0)
    • __y2 (starts as -1.0)
    • __win
    • It should accept new x/y coordinates as input, and set the __x1, __y1, __x2, and __y2 data members.
    • Then, if the cell has a left wall, draw it using Lines and Points.
    • If the cell has a top wall, draw it, and so on and so forth for each wall.