900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > python简单的青蛙旅行小游戏

python简单的青蛙旅行小游戏

时间:2024-07-02 12:35:03

相关推荐

python简单的青蛙旅行小游戏

青蛙旅行小游戏

'''青蛙旅行'''import os,time,sys,randomfrog_bag =[['Foods',1],['Water',1],['Medicine',1],['Games',1]]frog_refrigerator = [['Foods',1],['Water',1],['Medicine',1],['Games',1]]player_bag = [10, [['Foods',2],['Water',2],['Medicine',2],['Games',2]]]clove_count = 0frog_life = 3frog_name = []#进入游戏while True:os.system('cls')print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")print(" Welcome to the frog trip!")print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")while 1:#判断是否注册if not frog_name:print("Please give your little frog a name!")frog_name1=input("Plseas:")print("Your frog's name is:",frog_name1)print("Agree or not?")frog_name_choice = input("Please(Y/N):")#确认昵称if frog_name_choice == 'Y':print("Registered successfully!")frog_name.append(frog_name1)print("Your frog's name is:",frog_name[0])input("About to return to the superior menu...")os.system('cls')breakelse:print("Please input again!")continueelse:breakbreak#游戏选择功能界面while True:os.system('cls')print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")print(" Welcome to the frog trip!")print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")print(" HOME PAGE")print("1.Open the bag ")print("2.Open the refrigerator")print("3.Collect the clove ")print("4.Open the shop ")print("5.Enter the cabin ")print("6.Log out ")print(" ")print("Please select ")player_choice = input("Please:")#功能选择#打开背包if player_choice == '1':while 1:os.system('cls')print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")print(" Welcome to the frog's bag!")print("")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")print("Stock:",frog_bag)print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")print("1.Increase the items ")print("2.Return to previous menu")print("")print("Please select ")player_choice = input("Please:")#添加物品if player_choice == '1':while 1:os.system('cls')#青蛙背包print("")print("Frog_bag")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")print(frog_bag)print("")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")#玩家背包print("Player_bag")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")print(player_bag)print("")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")#展示食物选择print(" List of optional items")print("1.Foods ")print("2.Tirsty")print("3.Medicine ")print("4.Games")print("5.Return to previous menu")print("")player_choice = input("Please enter the items to be added:")#选择添加的食物if player_choice == '1':if player_bag[1][int(player_choice)-1][1] <= 0:input("Not enough stock...")else:player_bag[1][int(player_choice)-1][1] -=1frog_bag[int(player_choice)-1][1] +=1elif player_choice == '2':if player_bag[1][int(player_choice)-1][1] <= 0:input("Not enough stock...")else:player_bag[1][int(player_choice)-1][1] -=1frog_bag[int(player_choice)-1][1] +=1elif player_choice == '3':if player_bag[1][int(player_choice)-1][1] <= 0:input("Not enough stock...")else:player_bag[1][int(player_choice)-1][1] -=1frog_bag[int(player_choice)-1][1] +=1elif player_choice == '4':if player_bag[1][int(player_choice)-1][1] <= 0:input("Not enough stock...")else:player_bag[1][int(player_choice)-1][1] -=1frog_bag[int(player_choice)-1][1] +=1elif player_choice == '5':input("About to return to the superior menu...")breakelse:print("Please enter the correct number!")time.sleep(2)continuerequest = input("Whether to add or not(Y/N):")if request == 'Y':continueelse:print("N")#添加完成,展示青蛙背包input("Add completed, press any key to continue...")os.system('cls')print("")print("Frog_bag")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")print(frog_bag)print("")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")input("Press any key to continue...")break#返回上级菜单elif player_choice == '2':input("About to return to the superior menu...")break#输入错误else:print("Please enter the correct number!")time.sleep(2)continue#打开冰箱elif player_choice == '2':while 1:os.system('cls')print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")print(" Welcome to the frog's refrigerator!")print("")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")print("Stock:",frog_refrigerator)print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")print("1.Increase the items ")print("2.Return to previous menu")print("")print("Please select ")player_choice = input("Please:")#添加物品if player_choice == '1':while 1:os.system('cls')#青蛙冰箱print("")print("Frog_refrigerator")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")print(frog_refrigerator)print("")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")#玩家背包print("Player_bag")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")print(player_bag)print("")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")#展示食物选择print("List of optional items")print("1.Foods ")print("2.Water")print("3.Medicine ")print("4.Games")print("5.Return to previous menu")print("")player_choice = input("Please enter the food to be added:")#选择添加的食物if player_choice == '1':if player_bag[1][int(player_choice)-1][1] <=0 :input("Not enough stock...")else:player_bag[1][int(player_choice)-1][1] -=1frog_refrigerator[int(player_choice)-1][1] +=1elif player_choice == '2':if player_bag[1][int(player_choice)-1][1] <=0 :input("Not enough stock...")else:player_bag[1][int(player_choice)-1][1] -=1frog_refrigerator[int(player_choice)-1][1] +=1elif player_choice == '3':if player_bag[1][int(player_choice)-1][1] <=0 :input("Not enough stock...")else:player_bag[1][int(player_choice)-1][1] -=1frog_refrigerator[int(player_choice)-1][1] +=1elif player_choice == '4':if player_bag[1][int(player_choice)-1][1] <=0 :input("Not enough stock...")else:player_bag[1][int(player_choice)-1][1] -=1frog_refrigerator[int(player_choice)-1][1] +=1elif player_choice == '5':input("About to return to the superior menu...")breakelse:print("Please enter the correct number!")time.sleep(2)continuerequest = input("Whether to add or not(Y/N)")if request == 'Y':continueelse:print("N")#添加完成,展示青蛙冰箱input("Add completed, press any key to continue...")os.system('cls')print("")print("Frog_refrigerator")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")print(frog_refrigerator)print("")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")input("Press any key to continue...")break#返回上级菜单elif player_choice == '2':input("About to return to the superior menu...")break#输入错误else:print("Please enter the correct number!")time.sleep(2)continue#随机获取三叶草elif player_choice == '3':while 1:if clove_count <= 0:print("Run out of!")print("Please come back later")input("Press any key to continue...")breakelse:os.system('cls')print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")print(" Welcome to the frog's pond!")print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")input("Press any key to start collecting clove...")clove_count -= 1print("Residue degree",clove_count)clove_num = random.randint(1,30)player_bag[0] += clove_numprint("Collecting clove:",clove_num)print("ALL clove:",player_bag[0])request = input("Whether to add or not(Y/N):")if request == 'Y':continueelse:print("N")breakcontinue break#打开商店 elif player_choice == '4':while 1:os.system('cls')print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")print(" Welcome to the frog's shop!")print("")print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")print("")print("1.Foods(2clove) ")print("2.Water(1clove)")print("3.Medicine(5clove) ")print("4.Games(3clove)")print("5.Return to previous menu")print("")print("Your's clove:",player_bag[0])print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")print("Please select ")player_choice = input("Please:")#买1号食物if player_choice == '1':if player_bag[0] < 2:input("Sorry, your credit is running low")continueelse:print("Use 2clove for 1APPLE")player_bag[0] -=2player_bag[1][int(player_choice)-1][1] +=1print("player_bag:",player_bag)input("Press any key to continue...")#买2号食物elif player_choice == '2':if player_bag[0] < 1:input("Sorry, your credit is running low")continueelse:print("Use 1clove for 1APPLE")player_bag[0] -= 1player_bag[1][int(player_choice)-1][1] +=1print("player_bag:",player_bag)input("Press any key to continue...")#买3号食物elif player_choice == '3':if player_bag[0] < 5:input("Sorry, your credit is running low")continueelse:print("Use 5clove for 1APPLE")player_bag[0] -= 5player_bag[1][int(player_choice)-1][1] +=1print("player_bag:",player_bag)input("Press any key to continue...")#买4号食物elif player_choice == '4':if player_bag[0] < 3:input("Sorry, your credit is running low")continueelse:print("Use 3clove for 1APPLE")player_bag[0] -= 3player_bag[1][int(player_choice)-1][1] +=1print("player_bag:",player_bag)input("Press any key to continue...")#返回上一级 elif player_choice == '5':input("About to return to the superior menu...")break#错误输入else:print("Please enter the correct number!")input("Press any key to continue...")continuerequest = input("Whether to Continue Purchasing(Y/N):")if request == 'Y':continueelse:print("N")break#进入小屋elif player_choice == '5':while True:frog_play = random.randint(1,10)os.system('cls')print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")print(" Welcome to the frog's the cabin!")print("")print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")print("")if frog_life <= 0:os.system('cls')print("Unfortunately, your little frog died...")print(" ")print("The game will quit after 3S....")time.sleep(1)print("The game will quit after 2S....")time.sleep(1)print("The game will quit after 1S....")time.sleep(1)os.system('cls')print("THANKS!")sys.exit(1)breakelse:#出门玩耍if 1<= frog_play <5:while 1: #随机选的食物frog_xiaofei = random.choice(frog_bag)#随机选的食物的数量frog_food_num = frog_bag[frog_bag.index(frog_xiaofei)][1]if frog_food_num <= 0:frog_life -=1continueelse:frog_bag[frog_bag.index(frog_xiaofei)][1] -=1print("Going out to play...")print("Ate:",frog_xiaofei)input("Add completed, press any key to continue...")break#发呆elif 5<= frog_play <7:while 1:#随机选的食物frog_xiaofei = random.choice(frog_refrigerator)#随机选的食物的数量frog_food_num = frog_refrigerator[frog_refrigerator.index(frog_xiaofei)][1]if frog_food_num <= 0:frog_life -=1continueelse:frog_refrigerator[frog_refrigerator.index(frog_xiaofei)][1] -=1print("In a daze...")print("Ate:",frog_xiaofei)input("Add completed, press any key to continue...")break#学习elif 7<= frog_play <9:while 1:#随机选的食物frog_xiaofei = random.choice(frog_refrigerator)#随机选的食物的数量frog_food_num = frog_refrigerator[frog_refrigerator.index(frog_xiaofei)][1]if frog_food_num <= 0:frog_life -=1continueelse:frog_refrigerator[frog_refrigerator.index(frog_xiaofei)][1] -=1player_bag[0] += 5print("Learning...")print("Ate:",frog_xiaofei)input("Add completed, press any key to continue...")break#睡觉else:clove_count +=1print("Be sleeping ...")print("A day has passed...")input("Add completed, press any key to continue...")break#退出系统elif player_choice == '6':os.system('cls')print("The game will quit after 3S....")time.sleep(1)print("The game will quit after 2S....")time.sleep(1)print("The game will quit after 1S....")time.sleep(1)sys.exit(1) #输入选项错误else:print("Please enter the correct number!")time.sleep(2)continue

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。