I just started learning Python a couple of days ago as my first language and I ran into some trouble while trying to make a game. Here's the part I'm stuck at: Primary concern: I want it to randomly generate objects and doors. Secondary concern: I need each room to remember the objects even after I leave the room (Pots are destructible)
The problem: I want the program to spit out the number of pots,chests,superchests and doors , but the variables remain empty. Sorry for not framing the question more specifically, but I just started and the water is kinda murky in here D:
def random_room(pot, chest, schest, ldoor, rdoor, fdoor):
import random
loop = 0
pot = 0
chest = 0
schest = 0
ldoor = 0
rdoor = 0
fdoor = 0
while loop < 6:
rand = random.randint(0, 30)
if rand in range(1, 3, 1):
chest += 1
loop += 2
return chest
if rand in range(4,10, 1):
schest -= 1
return schest
if rand == 16:
schest += 1
loop += 3
return schest
if rand > 16:
pot += 1
loop +=1
return pot
if rand in range(10,12, 1):
ldoor = 1
return ldoor
if rand in range(12,14, 1):
fdoor = 1
return fdoor
if rand in range(14, 16, 1):
rdoor = 1
return rdoor
if schest < 0:
schest = 0
if rdoor + fdoor + ldoor == 0:
rand = random.randint(1,3)
if rand == 1:
rdoor += 1
if rand == 2:
ldoor += 1
if rand == 3:
fdoor += 1
random_room(pot, chest, schest, ldoor, rdoor, fdoor)
print pot
print ldoor
print rdoor
print fdoor
print chest
print schest
room = 2
while room == 2:
left_door = ""
right_door = ""
front_door = ""
print "You enter a room."
if chest == 1:
print "There is one CHEST in the room."
if chest > 1:
print "There are", chest, "CHESTs in the room."
if pot == 1:
print "There is one POT in the room."
if pot > 1:
print "THere are", pot, "POTs in the room."
if ldoor == 1:
left_door = "a door to the LEFT"
if rdoor == 1:
right_door = "a door to the RIGHT"
if fdoor == 1:
front_door = "a door in the FRONT"
if True:
print "There's", left_door, ",", right_door, ", and", front_door
break