猫史档案馆


【Python作品分享】zombierun【作品秀】

用户:屑雷神索尔屑雷神索尔查看:4 回复:1 评论:4 创建时间:2019-12-01T08:45:06


【作品展示】

center_image

 

【作品介绍】

这是一个游戏,大家可以来试试

 

【作品源代码】

import random


def zombie():

    x = random.randint(-20, 20)
    y = random.randint(-20, 20)
    return x, y


def dimond():
    x = random.randint(-20, 20)
    y = random.randint(-20, 20)
    return x, y


zombiex = [0]*40
zombiey = [0]*40
dimondx = [0]*40
dimondy = [0]*40
for a in range(40):

    zombiex[a], zombiey[a] = zombie()
    dimondx[a], dimondy[a] = dimond()
playerx = 0
playery = 0


dimond = 0
going = True
print(dimondx,dimondy,zombiex,zombiey)
while going:
    print(playerx, playery)
    print('你要向哪里走?(1前走、2左走、3右走)')
    choise =int(input())

    if choise == 1:
        playery += 1
    elif choise == 2:
        playerx -= 1
    elif choise == 3:
        playerx += 1
    ending=0
    for x in zombiex:
        for y in zombiey:
            if playerx == x and playery ==y:
                ending= 1
    for x in dimondx:
        for y in dimondy:
            if playerx == x and playery == y:
                ending= 2
    
                

    if ending == 1:
        print('真不幸!你被僵尸吃掉了!你的分数是:{}'.format(dimond))
        going = False
    elif ending == 2:
        print('哇塞!你捡到了一颗钻石!')
        dimond += 1
    else:
        print('什么也没有……')

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
比比芭比波哩波比比芭比波哩波

想法有意思,可不可以把这个游戏编程可视化的界面,然后界面里直接实现小人走动的效果呢

点赞0


评论