Nov-04-2016, 07:44 PM
Hi, I'm working on a game for a school project, and I've been trying to solve this problem for over a week now
(I'm working in Python 2.7, and I'm kind of new to Python, so...)
So even if i travel around the whole map, I can't "equip" anything
Please help!
(I'm working in Python 2.7, and I'm kind of new to Python, so...)
global world global shovel global pickaxe global detector global posx global posy world=[["a","b"],["c","d"],["e","f"]] shovel=0 pickaxe=0 detector=0 posx=0 posy=0 def Menu_Screen(): print "MENU" #Its in another program (i have to copy and paste this into that, but it works perfectly from there) def show_loc(): global posx global posy world_map=[["_","_"],["_","_"],["_","_"]] world_map[2-(posy)][posx]="X" for i in world_map: for j in i: print j,'\t', print def move_place(): global posx global posy global tempx global tempy tempx=posx tempy=posy show_loc() while True: m=raw_input("Which direction do you want to go? (N/S/E/W): ") while (posx==1 or posx==0) and (posy<=2 and posy>=0): if m.upper()=="E": tempx=tempx+1 elif m.upper()=="W": tempx=tempx-1 elif m.upper()=="N": tempy=tempy+1 elif m.upper()=="S": tempy=tempy-1 else: print "Invalid Input! Try again!" m="" break if (tempx==1 or tempx==0) and (tempy==0 or tempy==1 or tempy==2): posx=tempx posy=tempy show_loc() else: print "You can't move that way as it is blocked by a wall!" tempx=posx tempy=posy def Game_TRAPPED(): global posx global posy global pickaxe global shovel global detector global world move_place() p=world[posy][posx] if p=="a": if detector==0: print "You found a metal detector!" print "You've equipped the detector. Now to find something..." detector=detector+1 else: move_place() elif p=="c": if shovel==0 and detector==1: print "Your metal detector is beeping!" print "It looks like something is under the big rock in front of you" print "You push it as hard as you can..." print "You found a shovel!" print "Maybe you can find something else using this..." shovel=shovel+1 else: move_place() elif p=="d": if pickaxe==0 and (detector==1 and shovel==1): print "Your detector is beeping again!" print "But there's nothing there..." print "Maybe something is buried in this spot" print "You use the shovel and dig..." print "You found a pickaxe!" print "If only you knew the right place to strike..." pickaxe=pickaxe+1 else: move_place() elif p=="f": if pickaxe==0: print "The wall here seems kind of weak..." print "Mabye you could break this down and escape, but the rocks are too hard..." else: print "You used the pickaxe on the wall and escaped" print "YOU WON" print ""'\n' Menu_Screen() Game_TRAPPED()The game works fine except the player cannot "retrieve" any objects placed on the map.
So even if i travel around the whole map, I can't "equip" anything
Please help!