猫史档案馆


【Python作品分享】喂养金鱼【作品秀】

用户:BIBI多味豆BIBI多味豆查看:0 回复:1 评论:0 创建时间:2023-02-12T13:59:17


【作品展示】

center_image

 

【作品介绍】

喂养小金鱼。

eat,吃;lay,产卵。

小心别逝!

用的是随机数和循环,很简单的游戏,极简!

作者没学多少代码,不太会写,见谅!

点个赞再走吧~~~

豆子出品,必属精品。

 

【作品源代码】

import time
import random
hp = random.randint(50,115)
egg = 0


print('The next game began.')
time.sleep(1)
print("loading", end='', flush=True)
time.sleep(random.uniform(0.3,1.0))
print(".", end='', flush=True)
time.sleep(random.uniform(0.3, 1.0))
print(".", end='', flush=True)
time.sleep(random.uniform(0.3, 1.0))
print(".", end='', flush=True)
time.sleep(random.uniform(0.3, 1.0))
print(".", end='', flush=True)
time.sleep(random.uniform(0.3, 1.0))
print(".", end='', flush=True)
time.sleep(random.uniform(0.3, 1.0))
print(".")
time.sleep(2)
print('Load complete.')
time.sleep(1)
print('Initial saturation:', hp)
time.sleep(1)
print('Initial number of eggs:', egg)
time.sleep(2)
print('')

while True:
    a = input('eat or lay ? :')
    if a == 'eat':
        hp += random.randint(10,50)
        print('saturation:',hp,'eggs:',egg)
    elif a == 'lay':
        hp -= random.randint(10,40)
        egg += random.randint(1,10)
        print('saturation:', hp, 'eggs:', egg)
    else:
        print('Please enter the correct instructions:eat or lay.')
    if hp <= 0:
        print('it is died because it is very hungry.')
        time.sleep(0.5)
        print('Game over.')
        break
    if hp >= 170:
        print('it is died because it is very full.')
        time.sleep(0.5)
        print('Game over.')
        break
print('egg:',egg,'hp:',hp)

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
BIBI多味豆BIBI多味豆

作品在主页辣,自行浏览!

大佬们求带qwqemotion_兔子

点赞1


评论