diff --git a/grid_game.py b/grid_game.py index 64dd3da..f12f41b 100644 --- a/grid_game.py +++ b/grid_game.py @@ -8,11 +8,12 @@ (0, 3), (1, 3), (2, 3), (3, 3), (4, 3), (0, 4), (1, 4), (2, 4), (3, 4), (4, 4)] - +# Function to get locations of the grid def get_locations(): return random.sample(CELLS, 3) +# Function to move the player def move_player(player, move): x, y = player @@ -25,7 +26,7 @@ def move_player(player, move): if move == "DOWN": y += 1 return x, y - +# Function to get the player input to move in the grid def get_moves(player): moves = ["LEFT", "RIGHT", "UP", "DOWN"] @@ -40,6 +41,7 @@ def get_moves(player): moves.remove("DOWN") return moves +# Function to draw a map def draw_map(player, monster, door): print(" _"*5) @@ -70,6 +72,8 @@ def draw_map(player, monster, door): output = tile.format("_|") print(output, end=line_end) +# Function to loop the game till anyone wins + def game_loop(): monster, door, player = get_locations() playing = True @@ -104,10 +108,13 @@ def game_loop(): game_loop() +# Some print messages print("Welcome to the dungeon!") print("You have 1 life with you Try your luck!!") input("Press Enter to start!") +# Function call game_loop + game_loop()