Let's add another maze so that we have a bit more variety. Once I show you the process of adding another maze, then you can add as many mazes as your heart desires.
There are 2 text files that define a maze. For example, maze 1 has the following files: maze1.txt, maze1_rotation.txt.
I'm not going to do this here, but I highly suggest that you put these files in a separate folder so that your code is better organized.
The whole goal of this is to take everything that's maze specific in the run.py file and make it generic so that it can apply to any maze file. Mainly all of the stuff that's in the startGame method right now is only specific to the first maze. If we want the new maze above and any future mazes to work, we'll need to replace all of those hard-coded values with more generic code.
We'll start by creating a new file called "mazedata.py".
These are all of the values that are specific to the first maze. For every new maze that we make we'll need to make a new maze class with values that are specific to that maze. A lot of this should look familiar because I took it from the startGame method.
Similar to the previous class we'll have a class that has values specific to that maze. Notice here I have another portal pair. That's because this maze has 2 portal locations instead of just one.
This class just groups the maze classes together. We'll call the loadMaze method from the outside in order to get the maze object based on the level. Here we're just going to loop through the mazes with each successive level. So level 1 returns Maze1, level 2 returns Maze2, then level 3 will return Maze1 again and so on. If we had a third maze called Maze3, then level 3 would return that maze and level 4 would return Maze1 and so on and so forth.
So now we need to make all of these changes in the startGame method.
At this point we have 2 different distinct levels that we can play. In order to add more all we need to do is provide the 2 text files, provide the new class, and add that class to the MazeData class. So, for example, if we want to add a third level our text files will be called "maze3.txt" and "maze3_rotations.txt". Our new class will be called Maze3 and will be placed in the mazedata.py file similar to the other maze classes but with values specific to that maze. Then we add the Maze3 class to the MazeData classes mazedict dictionary.
Knowing that we can add as many levels as we want.