Problem in Dungeon & Dragon game with python
i just wrote this dungeon and dragon mini game, It's not completed yet , i didn't write the dragon function or the function to show an error when the user hits the wall. I just want to move the player " X " how many times i want , but i can't.
this is the code :
import random
import os
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
dungeon = [(0,0),(0,1),(0,2),(0,3),(0,4),
(1,0),(1,1),(1,2),(1,3),(1,4),
(2,0),(2,1),(2,2),(2,3),(2,4),
(3,0),(3,1),(3,2),(3,3),(3,4),
(4,0),(4,1),(4,2),(4,3),(4,4)
]
def first_random_position():
return(random.choice(dungeon))
def make_dungeon(player_position):
print(" _ _ _ _ _")
for cell in dungeon:
y = cell[1]
if y < 4:
if cell == player_position:
print("|X", end = "")
else:
print("|_", end = "")
elif cell == player_position:
print("|X|")
else:
print("|_|")
def move_player(position,m_input):
x,y = position
if m_input.upper() == "UP":
x -= 1
elif m_input.upper() == "LEFT":
y -= 1
elif m_input.upper() == "RIGHT":
y += 1
elif m_input.upper() == "DOWN":
x += 1
position = x,y
return(x,y)
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
first_pos = first_random_position()
make_dungeon(first_pos)
print("You are currently in room {}".format(first_pos))
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(first_pos,main_input)
clear_screen()
make_dungeon(location)
main()
as you can see, i just can move the X one time , but i want to be able to move it as many times as i want and i don't know how , i should write a while loop i guess? i tried but i failed and I really need your help . thanks
python while-loop
add a comment |
i just wrote this dungeon and dragon mini game, It's not completed yet , i didn't write the dragon function or the function to show an error when the user hits the wall. I just want to move the player " X " how many times i want , but i can't.
this is the code :
import random
import os
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
dungeon = [(0,0),(0,1),(0,2),(0,3),(0,4),
(1,0),(1,1),(1,2),(1,3),(1,4),
(2,0),(2,1),(2,2),(2,3),(2,4),
(3,0),(3,1),(3,2),(3,3),(3,4),
(4,0),(4,1),(4,2),(4,3),(4,4)
]
def first_random_position():
return(random.choice(dungeon))
def make_dungeon(player_position):
print(" _ _ _ _ _")
for cell in dungeon:
y = cell[1]
if y < 4:
if cell == player_position:
print("|X", end = "")
else:
print("|_", end = "")
elif cell == player_position:
print("|X|")
else:
print("|_|")
def move_player(position,m_input):
x,y = position
if m_input.upper() == "UP":
x -= 1
elif m_input.upper() == "LEFT":
y -= 1
elif m_input.upper() == "RIGHT":
y += 1
elif m_input.upper() == "DOWN":
x += 1
position = x,y
return(x,y)
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
first_pos = first_random_position()
make_dungeon(first_pos)
print("You are currently in room {}".format(first_pos))
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(first_pos,main_input)
clear_screen()
make_dungeon(location)
main()
as you can see, i just can move the X one time , but i want to be able to move it as many times as i want and i don't know how , i should write a while loop i guess? i tried but i failed and I really need your help . thanks
python while-loop
1
Read about loops here: docs.python.org/3/tutorial/…
– Patrick Artner
Dec 28 '18 at 13:56
1
What did you try? How did it fail?
– larsks
Dec 28 '18 at 14:10
@PatrickArtner I know how loops work , i used them before , but in this case i dont know what i should do , writing a while loop only helps to take input again and again , but it doesnt solve my problem . i want to move the player but i have problem with the location , i cant update the location each time
– Shah
Dec 28 '18 at 14:41
add a comment |
i just wrote this dungeon and dragon mini game, It's not completed yet , i didn't write the dragon function or the function to show an error when the user hits the wall. I just want to move the player " X " how many times i want , but i can't.
this is the code :
import random
import os
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
dungeon = [(0,0),(0,1),(0,2),(0,3),(0,4),
(1,0),(1,1),(1,2),(1,3),(1,4),
(2,0),(2,1),(2,2),(2,3),(2,4),
(3,0),(3,1),(3,2),(3,3),(3,4),
(4,0),(4,1),(4,2),(4,3),(4,4)
]
def first_random_position():
return(random.choice(dungeon))
def make_dungeon(player_position):
print(" _ _ _ _ _")
for cell in dungeon:
y = cell[1]
if y < 4:
if cell == player_position:
print("|X", end = "")
else:
print("|_", end = "")
elif cell == player_position:
print("|X|")
else:
print("|_|")
def move_player(position,m_input):
x,y = position
if m_input.upper() == "UP":
x -= 1
elif m_input.upper() == "LEFT":
y -= 1
elif m_input.upper() == "RIGHT":
y += 1
elif m_input.upper() == "DOWN":
x += 1
position = x,y
return(x,y)
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
first_pos = first_random_position()
make_dungeon(first_pos)
print("You are currently in room {}".format(first_pos))
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(first_pos,main_input)
clear_screen()
make_dungeon(location)
main()
as you can see, i just can move the X one time , but i want to be able to move it as many times as i want and i don't know how , i should write a while loop i guess? i tried but i failed and I really need your help . thanks
python while-loop
i just wrote this dungeon and dragon mini game, It's not completed yet , i didn't write the dragon function or the function to show an error when the user hits the wall. I just want to move the player " X " how many times i want , but i can't.
this is the code :
import random
import os
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
dungeon = [(0,0),(0,1),(0,2),(0,3),(0,4),
(1,0),(1,1),(1,2),(1,3),(1,4),
(2,0),(2,1),(2,2),(2,3),(2,4),
(3,0),(3,1),(3,2),(3,3),(3,4),
(4,0),(4,1),(4,2),(4,3),(4,4)
]
def first_random_position():
return(random.choice(dungeon))
def make_dungeon(player_position):
print(" _ _ _ _ _")
for cell in dungeon:
y = cell[1]
if y < 4:
if cell == player_position:
print("|X", end = "")
else:
print("|_", end = "")
elif cell == player_position:
print("|X|")
else:
print("|_|")
def move_player(position,m_input):
x,y = position
if m_input.upper() == "UP":
x -= 1
elif m_input.upper() == "LEFT":
y -= 1
elif m_input.upper() == "RIGHT":
y += 1
elif m_input.upper() == "DOWN":
x += 1
position = x,y
return(x,y)
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
first_pos = first_random_position()
make_dungeon(first_pos)
print("You are currently in room {}".format(first_pos))
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(first_pos,main_input)
clear_screen()
make_dungeon(location)
main()
as you can see, i just can move the X one time , but i want to be able to move it as many times as i want and i don't know how , i should write a while loop i guess? i tried but i failed and I really need your help . thanks
python while-loop
python while-loop
asked Dec 28 '18 at 13:53
ShahShah
51
51
1
Read about loops here: docs.python.org/3/tutorial/…
– Patrick Artner
Dec 28 '18 at 13:56
1
What did you try? How did it fail?
– larsks
Dec 28 '18 at 14:10
@PatrickArtner I know how loops work , i used them before , but in this case i dont know what i should do , writing a while loop only helps to take input again and again , but it doesnt solve my problem . i want to move the player but i have problem with the location , i cant update the location each time
– Shah
Dec 28 '18 at 14:41
add a comment |
1
Read about loops here: docs.python.org/3/tutorial/…
– Patrick Artner
Dec 28 '18 at 13:56
1
What did you try? How did it fail?
– larsks
Dec 28 '18 at 14:10
@PatrickArtner I know how loops work , i used them before , but in this case i dont know what i should do , writing a while loop only helps to take input again and again , but it doesnt solve my problem . i want to move the player but i have problem with the location , i cant update the location each time
– Shah
Dec 28 '18 at 14:41
1
1
Read about loops here: docs.python.org/3/tutorial/…
– Patrick Artner
Dec 28 '18 at 13:56
Read about loops here: docs.python.org/3/tutorial/…
– Patrick Artner
Dec 28 '18 at 13:56
1
1
What did you try? How did it fail?
– larsks
Dec 28 '18 at 14:10
What did you try? How did it fail?
– larsks
Dec 28 '18 at 14:10
@PatrickArtner I know how loops work , i used them before , but in this case i dont know what i should do , writing a while loop only helps to take input again and again , but it doesnt solve my problem . i want to move the player but i have problem with the location , i cant update the location each time
– Shah
Dec 28 '18 at 14:41
@PatrickArtner I know how loops work , i used them before , but in this case i dont know what i should do , writing a while loop only helps to take input again and again , but it doesnt solve my problem . i want to move the player but i have problem with the location , i cant update the location each time
– Shah
Dec 28 '18 at 14:41
add a comment |
1 Answer
1
active
oldest
votes
When you run the lines:
main_input = input("n")
location = move_player(first_pos,main_input)
clear_screen()
make_dungeon(location)
It asks for the user input only once as Patrick Artner commented you need to use loops within your script.
If you surround that script with while True:
it should let you continue to move:
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
location = first_random_position()
make_dungeon(location)
print("You are currently in room {}".format(location))
while True:
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(location,main_input)
clear_screen()
make_dungeon(location)
You should use location
rather than first_pos
because it updates with the previous movement.
Although this is unrelated to the question I feel these changes will help your code for the future. Firstly, I would recommend adding elif m_input.upper() == "QUIT": exit()
as a temporary way to exit your game. Secondly, rather than writing out the dungeon variable use list comprehension to create it dungeon = [(x,y) for x in range(5) for y in range(5)]
.
The Full Updated Code
import random
import os
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
dimensions = (6,6)
dungeon = [(x,y) for x in range(dimensions[0]) for y in range(dimensions[1])]
def first_random_position():
return(random.choice(dungeon))
def make_dungeon(player_position):
print(" _"*dimensions[1])
for cell in dungeon:
y = cell[1]
if y < dimensions[1]-1:
if cell == player_position:
print("|X", end = "")
else:
print("|_", end = "")
elif cell == player_position:
print("|X|")
else:
print("|_|")
def move_player(position,m_input):
x,y = position
if m_input.upper() == "UP":
x -= 1
elif m_input.upper() == "LEFT":
y -= 1
elif m_input.upper() == "RIGHT":
y += 1
elif m_input.upper() == "DOWN":
x += 1
elif m_input.upper() == "QUIT":
exit()
position = x,y
return(x,y)
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
location = first_random_position()
make_dungeon(location)
print("You are currently in room {}".format(location))
while True:
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(location,main_input)
clear_screen()
make_dungeon(location)
main()
Hope this helped.
Here is a simple explanation of the table for future reference:
1
Thanks for your response , but it only lets me to take input from user again again , i tried it before , my problem is with the location , it doesn't get updated each time. is it possible to write a function to return the location of X ? and thanks for your recommendation, i added that elif statement. edit : Thanks , i just saw you updated your answer , and it really helped me
– Shah
Dec 28 '18 at 14:46
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53959646%2fproblem-in-dungeon-dragon-game-with-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
When you run the lines:
main_input = input("n")
location = move_player(first_pos,main_input)
clear_screen()
make_dungeon(location)
It asks for the user input only once as Patrick Artner commented you need to use loops within your script.
If you surround that script with while True:
it should let you continue to move:
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
location = first_random_position()
make_dungeon(location)
print("You are currently in room {}".format(location))
while True:
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(location,main_input)
clear_screen()
make_dungeon(location)
You should use location
rather than first_pos
because it updates with the previous movement.
Although this is unrelated to the question I feel these changes will help your code for the future. Firstly, I would recommend adding elif m_input.upper() == "QUIT": exit()
as a temporary way to exit your game. Secondly, rather than writing out the dungeon variable use list comprehension to create it dungeon = [(x,y) for x in range(5) for y in range(5)]
.
The Full Updated Code
import random
import os
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
dimensions = (6,6)
dungeon = [(x,y) for x in range(dimensions[0]) for y in range(dimensions[1])]
def first_random_position():
return(random.choice(dungeon))
def make_dungeon(player_position):
print(" _"*dimensions[1])
for cell in dungeon:
y = cell[1]
if y < dimensions[1]-1:
if cell == player_position:
print("|X", end = "")
else:
print("|_", end = "")
elif cell == player_position:
print("|X|")
else:
print("|_|")
def move_player(position,m_input):
x,y = position
if m_input.upper() == "UP":
x -= 1
elif m_input.upper() == "LEFT":
y -= 1
elif m_input.upper() == "RIGHT":
y += 1
elif m_input.upper() == "DOWN":
x += 1
elif m_input.upper() == "QUIT":
exit()
position = x,y
return(x,y)
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
location = first_random_position()
make_dungeon(location)
print("You are currently in room {}".format(location))
while True:
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(location,main_input)
clear_screen()
make_dungeon(location)
main()
Hope this helped.
Here is a simple explanation of the table for future reference:
1
Thanks for your response , but it only lets me to take input from user again again , i tried it before , my problem is with the location , it doesn't get updated each time. is it possible to write a function to return the location of X ? and thanks for your recommendation, i added that elif statement. edit : Thanks , i just saw you updated your answer , and it really helped me
– Shah
Dec 28 '18 at 14:46
add a comment |
When you run the lines:
main_input = input("n")
location = move_player(first_pos,main_input)
clear_screen()
make_dungeon(location)
It asks for the user input only once as Patrick Artner commented you need to use loops within your script.
If you surround that script with while True:
it should let you continue to move:
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
location = first_random_position()
make_dungeon(location)
print("You are currently in room {}".format(location))
while True:
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(location,main_input)
clear_screen()
make_dungeon(location)
You should use location
rather than first_pos
because it updates with the previous movement.
Although this is unrelated to the question I feel these changes will help your code for the future. Firstly, I would recommend adding elif m_input.upper() == "QUIT": exit()
as a temporary way to exit your game. Secondly, rather than writing out the dungeon variable use list comprehension to create it dungeon = [(x,y) for x in range(5) for y in range(5)]
.
The Full Updated Code
import random
import os
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
dimensions = (6,6)
dungeon = [(x,y) for x in range(dimensions[0]) for y in range(dimensions[1])]
def first_random_position():
return(random.choice(dungeon))
def make_dungeon(player_position):
print(" _"*dimensions[1])
for cell in dungeon:
y = cell[1]
if y < dimensions[1]-1:
if cell == player_position:
print("|X", end = "")
else:
print("|_", end = "")
elif cell == player_position:
print("|X|")
else:
print("|_|")
def move_player(position,m_input):
x,y = position
if m_input.upper() == "UP":
x -= 1
elif m_input.upper() == "LEFT":
y -= 1
elif m_input.upper() == "RIGHT":
y += 1
elif m_input.upper() == "DOWN":
x += 1
elif m_input.upper() == "QUIT":
exit()
position = x,y
return(x,y)
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
location = first_random_position()
make_dungeon(location)
print("You are currently in room {}".format(location))
while True:
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(location,main_input)
clear_screen()
make_dungeon(location)
main()
Hope this helped.
Here is a simple explanation of the table for future reference:
1
Thanks for your response , but it only lets me to take input from user again again , i tried it before , my problem is with the location , it doesn't get updated each time. is it possible to write a function to return the location of X ? and thanks for your recommendation, i added that elif statement. edit : Thanks , i just saw you updated your answer , and it really helped me
– Shah
Dec 28 '18 at 14:46
add a comment |
When you run the lines:
main_input = input("n")
location = move_player(first_pos,main_input)
clear_screen()
make_dungeon(location)
It asks for the user input only once as Patrick Artner commented you need to use loops within your script.
If you surround that script with while True:
it should let you continue to move:
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
location = first_random_position()
make_dungeon(location)
print("You are currently in room {}".format(location))
while True:
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(location,main_input)
clear_screen()
make_dungeon(location)
You should use location
rather than first_pos
because it updates with the previous movement.
Although this is unrelated to the question I feel these changes will help your code for the future. Firstly, I would recommend adding elif m_input.upper() == "QUIT": exit()
as a temporary way to exit your game. Secondly, rather than writing out the dungeon variable use list comprehension to create it dungeon = [(x,y) for x in range(5) for y in range(5)]
.
The Full Updated Code
import random
import os
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
dimensions = (6,6)
dungeon = [(x,y) for x in range(dimensions[0]) for y in range(dimensions[1])]
def first_random_position():
return(random.choice(dungeon))
def make_dungeon(player_position):
print(" _"*dimensions[1])
for cell in dungeon:
y = cell[1]
if y < dimensions[1]-1:
if cell == player_position:
print("|X", end = "")
else:
print("|_", end = "")
elif cell == player_position:
print("|X|")
else:
print("|_|")
def move_player(position,m_input):
x,y = position
if m_input.upper() == "UP":
x -= 1
elif m_input.upper() == "LEFT":
y -= 1
elif m_input.upper() == "RIGHT":
y += 1
elif m_input.upper() == "DOWN":
x += 1
elif m_input.upper() == "QUIT":
exit()
position = x,y
return(x,y)
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
location = first_random_position()
make_dungeon(location)
print("You are currently in room {}".format(location))
while True:
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(location,main_input)
clear_screen()
make_dungeon(location)
main()
Hope this helped.
Here is a simple explanation of the table for future reference:
When you run the lines:
main_input = input("n")
location = move_player(first_pos,main_input)
clear_screen()
make_dungeon(location)
It asks for the user input only once as Patrick Artner commented you need to use loops within your script.
If you surround that script with while True:
it should let you continue to move:
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
location = first_random_position()
make_dungeon(location)
print("You are currently in room {}".format(location))
while True:
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(location,main_input)
clear_screen()
make_dungeon(location)
You should use location
rather than first_pos
because it updates with the previous movement.
Although this is unrelated to the question I feel these changes will help your code for the future. Firstly, I would recommend adding elif m_input.upper() == "QUIT": exit()
as a temporary way to exit your game. Secondly, rather than writing out the dungeon variable use list comprehension to create it dungeon = [(x,y) for x in range(5) for y in range(5)]
.
The Full Updated Code
import random
import os
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
dimensions = (6,6)
dungeon = [(x,y) for x in range(dimensions[0]) for y in range(dimensions[1])]
def first_random_position():
return(random.choice(dungeon))
def make_dungeon(player_position):
print(" _"*dimensions[1])
for cell in dungeon:
y = cell[1]
if y < dimensions[1]-1:
if cell == player_position:
print("|X", end = "")
else:
print("|_", end = "")
elif cell == player_position:
print("|X|")
else:
print("|_|")
def move_player(position,m_input):
x,y = position
if m_input.upper() == "UP":
x -= 1
elif m_input.upper() == "LEFT":
y -= 1
elif m_input.upper() == "RIGHT":
y += 1
elif m_input.upper() == "DOWN":
x += 1
elif m_input.upper() == "QUIT":
exit()
position = x,y
return(x,y)
def main():
print("Welcome to the Dungeon!")
input("Press 'Enter' on your keyboard to start the game!")
location = first_random_position()
make_dungeon(location)
print("You are currently in room {}".format(location))
while True:
print("Enter LEFT , RIGHT , UP and DOWN to move the 'X'")
print("Enter 'QUIT' to quit")
main_input = input("n")
location = move_player(location,main_input)
clear_screen()
make_dungeon(location)
main()
Hope this helped.
Here is a simple explanation of the table for future reference:
edited Dec 28 '18 at 15:00
answered Dec 28 '18 at 14:13
wowchawowcha
9711
9711
1
Thanks for your response , but it only lets me to take input from user again again , i tried it before , my problem is with the location , it doesn't get updated each time. is it possible to write a function to return the location of X ? and thanks for your recommendation, i added that elif statement. edit : Thanks , i just saw you updated your answer , and it really helped me
– Shah
Dec 28 '18 at 14:46
add a comment |
1
Thanks for your response , but it only lets me to take input from user again again , i tried it before , my problem is with the location , it doesn't get updated each time. is it possible to write a function to return the location of X ? and thanks for your recommendation, i added that elif statement. edit : Thanks , i just saw you updated your answer , and it really helped me
– Shah
Dec 28 '18 at 14:46
1
1
Thanks for your response , but it only lets me to take input from user again again , i tried it before , my problem is with the location , it doesn't get updated each time. is it possible to write a function to return the location of X ? and thanks for your recommendation, i added that elif statement. edit : Thanks , i just saw you updated your answer , and it really helped me
– Shah
Dec 28 '18 at 14:46
Thanks for your response , but it only lets me to take input from user again again , i tried it before , my problem is with the location , it doesn't get updated each time. is it possible to write a function to return the location of X ? and thanks for your recommendation, i added that elif statement. edit : Thanks , i just saw you updated your answer , and it really helped me
– Shah
Dec 28 '18 at 14:46
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53959646%2fproblem-in-dungeon-dragon-game-with-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Read about loops here: docs.python.org/3/tutorial/…
– Patrick Artner
Dec 28 '18 at 13:56
1
What did you try? How did it fail?
– larsks
Dec 28 '18 at 14:10
@PatrickArtner I know how loops work , i used them before , but in this case i dont know what i should do , writing a while loop only helps to take input again and again , but it doesnt solve my problem . i want to move the player but i have problem with the location , i cant update the location each time
– Shah
Dec 28 '18 at 14:41