Skip to content

Dungeon Maze is a Python 3 application built using the turtle graphics library. Using keyboard keys, the player can navigate through the dungeon, collect apples, and exit to safety. Creating the player board was achieved by utilizing the Pen class from Turtle graphics, effectively drawing a space of 750x750px. Pre-made graphics were imported fro…

neillsom/py-maze

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dungeon Maze: Python Game

Dungeon Maze is a Python 3 application built using the turtle graphics library. Using keyboard keys, the player can navigate through the dungeon, collect apples, and exit to safety. Creating the player board was achieved by utilizing the Pen class from Turtle graphics, effectively drawing a space of 750x750px. Premade graphics were imported from Unity Engine free assets and assigned to classes respectively.

Project Links

Screenshots

Dungeon maze: Dungeon maze

Tech / Frameworks used

Built with

  • Python3
  • Turtle graphics

Code Examples

Create level setup function

def create_maze(level):
    for y in range(len(level)):
        for x in range(len(level[y])):
            # get the character at eaxy x,y coordinate
            # note the order of y and x in next line
            character = level[y][x]
            # calculate the screen x,y coordinates
            screen_x = -288 + (x * 24)
            screen_y = 288 - (y * 24)

            # check if it is an x
            if character == 'X':
                pen.goto(screen_x, screen_y)
                pen.shape('./resources/texture-2.gif')
                pen.stamp()
                # add coordinates to wall list
                walls.append((screen_x, screen_y)) # tuple coordinate pair

            if character == '@':
                player.goto(screen_x, screen_y)

            if character == 'O':
                bootys.append(Booty(screen_x, screen_y))

Code to register collisions

 # code to register collisions
    def is_collision(self, other):
        a = self.xcor()-other.xcor()
        b = self.ycor()-other.ycor()
        # a² + b² = c² to calc distance
        playerDis = math.sqrt((a ** 2) + (b ** 2))

        if playerDis < 5: # pixels
            return True
        else:
            return False

License

MIT License Copyright (c) 2018 Neill Somerville

About

Dungeon Maze is a Python 3 application built using the turtle graphics library. Using keyboard keys, the player can navigate through the dungeon, collect apples, and exit to safety. Creating the player board was achieved by utilizing the Pen class from Turtle graphics, effectively drawing a space of 750x750px. Pre-made graphics were imported fro…

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages