Always be looking for a user input -
i trying creating small "game" , 1 of things can go hunting. (code isn't clean want see if works first) when "hunting" it's going find random items want when user types "stop" stops hunting items. , carrying until has typed "stop".
how go around doing that? thanks.
code hunting function:
def gohunting(q): on_hunt = true while on_hunt == true: rand = random.randint(1,1) rand2 = random.randint(0,8) rand3 = random.randint(1,20) rand4 = random.randint(1,5) time.sleep(rand) found = items[rand2] if found == "axe": print("you found axe!") axe += rand3 elif found == 'stick': amount = rand3 amount2 = str(amount) amount2 = "[" + amount2 + "]" print("you found sticks", amount2) stick += amount elif found == 'twig': amount = amount amount2 = str(amount) amount2 = "[" + amount2 + "]" print("you found twigs", amount2) twig += amount elif found == 'rock': amount = rand3 amount2 = str(amount) amount2 = "[" + amount2 + "]" print("you found rocks!", amount2) rock += amount elif found == 'grass': amount = rand3 amount2 = str(amount) amount2 = "[" + amount2 + "]" print("you found grass!", amount2) grass += amount elif found == 'flint': amount = rand3 amount2 = str(amount) amount2 = "[" + amount2 + "]" print("you found flint!", amount2) flint += amount elif found == 'tree': print("you came across tree") if axe > 0: print("you used axe chop", rand4) elif found == 'rare': rand5 = random.randint(1,3) if rand5 == 2: amount = rand3 amount2 = str(amount) amount2 = "[" + amount2 + "]" print("_"*40, "\n") print("[rare] - found iron", amount2) print("_"*40) iron += amount
Comments
Post a Comment