PyZombis Pandas@3763880
  • Social
    • Runestone in social media:
      Follow @iRunestone Our Facebook Page
    • Help support us:
  • Search
    • Table of Contents
    • Book Index
  • User
    • Not logged in
    • Assignments
    • Practice
    • Change Course
    • Instructor's Page
    • Progress Page
    • Edit Profile
    • Change Password
    • Register
    • Login
    • Dark Mode
  • Scratch Activecode
  • Help
    • FAQ
    • Instructors Guide
    • About Runestone
    • Report A Problem
  • 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))
     
    1
    import pygame
    2
    from pygame.color import *
    3
    from pygame.locals import *
    4
    from pygame import mixer
    5
    ​
    6
    ​
    7
    # game which has a maze and a player
    8
    # player has to reach the end of the maze
    9
    class Maze:
    10
    ​
    11
        def __init__(self,maze=None):
    12
            self.maze = maze
    13
            self.rows = self.maze.__len__()
    14
            self.cols = self.maze[0].__len__()
    15
    ​
    16
    ​
    17
        def draw(self,screen):
    18
    ​
    19
            rows = self.rows
    20
            cols = self.cols
    21
            for i in range(rows):
    22
                for j in range(cols):
    23
    ​
    24
                    if self.maze[i][j] == 1:

    Activity: 1 ActiveCode (ac_r04_en)

    You have attempted 1 of 2 activities on this page
user not logged in

Scratch ActiveCode

Use this area for writing code or taking notes.

                  

ActiveCode (PyZombis_scratch_ac)