Dungeon Game Prototype


#1

The idea came from the Battleship Lesson.
If you have any thoughts, nitpicks, or comments, feel free to leave them. :slight_smile:

room = []

for x in range(0, 5):
room.append(["#"] * 5)

def print_room(room):
for row in room:
print " ".join(row)

room[1][3] = β€œW”

motion = False

def rebound(yco, xco):
global ycoord
global xcoord
if user_input == β€œw”:
yco += 1
ycoord += 1
room[yco][xco] = β€œG”
print_room(room)
elif user_input == β€œs”:
yco -= 1
ycoord -= 1
room[yco][xco] = β€œG”
print_room(room)
elif user_input == β€œa”:
xco += 1
xcoord += 1
room[yco][xco] = β€œG”
print_room(room)
elif user_input == β€œd”:
xco -= 1
xcoord -= 1
room[yco][xco] = β€œG”
print_room(room)

ycoord = 2
xcoord = 2
room[xcoord][ycoord] = β€œG”

print_room(room)

def testspot(yco, xco):
if room[yco][xco] == β€œ#”:
room[yco][xco] = β€œG”
print_room(room)
else:
print β€œWALL BOI”
global user_input
global xcoord
global ycoord
rebound(yco, xco)

running = 0
death = False
def turn(run):
global running
running += 1
global user_input
user_input = raw_input("Enter: ")

def move(direction):
global ycoord
global xcoord
global motion
motion = True
if direction == β€œw”:
if ycoord == 0:
print β€œThere is no door there.”
print_room(room)
else:
room[ycoord][xcoord] = β€œ#”
ycoord -= 1
testspot(ycoord, xcoord)
elif direction == β€œs”:
if ycoord == 4:
print β€œThere is no door there.”
print_room(room)
else:
room[ycoord][xcoord] = β€œ#”
ycoord += 1
testspot(ycoord, xcoord)
elif direction == β€œa”:
if xcoord == 0:
print β€œThere is no door there.”
print_room(room)
else:
room[ycoord][xcoord] = β€œ#”
xcoord -= 1
testspot(ycoord, xcoord)
elif direction == β€œd”:
if xcoord == 4:
print β€œThere is no door there.”
print_room(room)
else:
room[ycoord][xcoord] = β€œ#”
xcoord += 1
testspot(ycoord, xcoord)
else:
print β€œlol wut”

while running >= 0 and death == False:
turn(8)
print running
global user_input
if user_input == β€œend”:
break
elif user_input == β€œsad”:
death = True
else:
move(user_input)