I am currently trying to create a maze game by following some online tutorials, and putting my own spin on them. I found a pretty good tutorial at pythonspot.com, but I am not sure what some of the code means, and if I have to use images and sprites to create this maze.
The piece that is confusing me is this:
class Maze: def __init__(self): self.M = 10 self.N = 8 self.maze = [ 1,1,1,1,1,1,1,1,1,1, 1,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,1, 1,0,1,1,1,1,1,1,0,1, 1,0,1,0,0,0,0,0,0,1, 1,0,1,0,1,1,1,1,0,1, 1,0,0,0,0,0,0,0,0,1, 1,1,1,1,1,1,1,1,1,1,] def draw(self,display_surf,image_surf): bx = 0 by = 0 for i in range(0,self.M*self.N): if self.maze[ bx + (by*self.M) ] == 1: display_surf.blit(image_surf,( bx * 44 , by * 44)) bx = bx + 1 if bx > self.M-1: bx = 0 by = by + 1
I know that you can make a maze with
0s to print to the screen, and this is easier for me to make levels with, because I can visualize them in the
Do I have to use images like the tutorial is (
display_surf.blit(image_surf)), or can I use
pygame.draw to create a square for use multiple times as a wall?
I was also wondering what the
by variables do
I have tried looking at other mazes, on the Internet, but they tend to either draw all of the walls as lines in individual
draw statements without using
0s, or they use sprites to create the player and walls. This leads me to believe that I have to use sprites for this drawing method, but I thought I would check here to make sure. I would ask the creator of the tutorial, but I can not create an account for the website, and can not ask questions or leave comments without an account.