PyMaze¶
Goals:¶
Complete the solve_maze function
Description:
This function takes maze object as input and determines if there is a path from start(0,0) to end(3)
1 is a wall
2 is a Zombie
3 is destination
0 is all the free path
Complete the run function which handles key events to move player in maze
- Complete the play_music function which takes audio from file solve_maze.ogg and plays on running the code
file path for solveMusic is ../../audio/solve_maze.ogg
179
game = font.render('Game Over -\n Press run to Play Again',True, Color(0,0,0))
import pygame
from pygame.color import *
from pygame.locals import *
from pygame import mixer
# game which has a maze and a player
# player has to reach the end of the maze
class Maze:
def __init__(self,maze=None):
self.maze = maze
self.rows = self.maze.__len__()
self.cols = self.maze[0].__len__()
def draw(self,screen):
rows = self.rows
cols = self.cols
for i in range(rows):
for j in range(cols):
if self.maze[i][j] == 1:
Activity: 1 ActiveCode (ac_r04_en)
You have attempted 1 of 2 activities on this page