Search⌘ K

Introducing Sphere Mazes

Explore how to create sphere mazes by building on polar grid concepts. Learn to subclass grids into hemispheres and combine them into a full sphere. Understand the mathematical adjustments required for spherical layouts and the unique challenges of configuring cells along the equator. This lesson prepares you to implement spherical mazes with adaptable grid structures.

Understanding sphere mazes

Creating a maze on the surface of a sphere shares a lot in common with creating a maze inside of a circle, which isn’t surprising! A hemisphere, after all, is just a circle that’s been lifted up by its origin like this:

Illustration of a hemisphere, represented as a circle that’s been lifted up by its origin
Illustration of a hemisphere, represented as a circle that’s been lifted up by its origin

We can create a sphere by putting two hemispheres together, which means we should be able to implement a spherical grid by leaning on our polar grid. We’ll need to change a lot of the calculations behind the measuring of the cells, and our to_png method is going to need rewriting, but it’s a start.

So here’s what we’ll do. We’ll subclass our PolarGrid to make a HemisphereGrid, and then glue two of those together to make a SphereGrid. We’ll put all these in the same ...