注册 登录
编程论坛 Python论坛

今天分享一个小游戏!大家评估一下!

一张白纸123 发布于 2023-09-03 12:31, 562 次点击
程序代码:
def init():
    global home,xy_x,xy_y
    home=['#','#','#','#','#','#','#','#','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#','#','#','#','#','#','#','#','#']

    xy_x=[]
    xy_y=[]
    for y in range(0,18):
        xy_y.append('%d'%(y))

    for x in range(0,10):
        xy_x.append('%d'%(x))

    print('玩法:x*y得出位置,方块类型是符号,但必须是一个字节的。')

    k=input('玩耍之初,推荐一个方块类型呗!')
    if len(k)==1 and k!=' ':
        print('符合要求,谢谢推荐!')

    else:
        print('欢迎来到"home"!')
   
def main():
    global home,xy_x,xy_y
    init()
    while True:
        x=0
        for i in range(len(home)):
            x+=1
            if x==10:
                x=0
                x+=1
                print('\n',end='')
            print(home[i],end=' ')

        print('\n')
        
        k=input('方块类型:')
        if len(k)!=1:
            print('只输入一个字节的数!')
            continue
        
        X=input('选择方位x:')
        if X not in xy_x:
            print('不在方位列表之中。')
            continue
        
        Y=input('选择方位y:')
        if Y not in xy_y:
            print('不在方位列表之中。')

        home[int(X)*(int(Y)+9)]=k

if __name__=='__main__':
    main()
征求大家的意见!谢谢
5 回复
#2
一张纸白2023-09-03 12:44
有bug
#3
一张白纸1232023-09-03 12:47
不好意思,我发个它的0.0.2版本
代码程序:
def init():
    global home,xy_x,xy_y
    home=['#','#','#','#','#','#','#','#','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#',' ',' ',' ',' ',' ',' ',' ','#',
          '#','#','#','#','#','#','#','#','#']

    xy_x=[]
    xy_y=[]
    for y in range(0,18):
        xy_y.append('%d'%(y))

    for x in range(0,10):
        xy_x.append('%d'%(x))

    print('玩法:x*y得出位置,方块类型是符号,但必须是一个字节的。')

    k=input('玩耍之初,推荐一个方块类型呗!')
    if len(k)==1 and k!=' ':
        print('符合要求,谢谢推荐!')

    else:
        print('欢迎来到"home"!')
   
def main():
    global home,xy_x,xy_y
    init()
    while True:
        x=0
        for i in range(len(home)):
            x+=1
            if x==10:
                x=0
                x+=1
                print('\n',end='')
            print(home[i],end=' ')

        print('\n')
        
        k=input('方块类型:')
        if len(k)!=1:
            print('只输入一个字节的数!')
            continue
        
        X=input('选择方位x:')
        if X not in xy_x:
            print('不在方位列表之中。')
            continue
        
        Y=input('选择方位y:')
        if Y not in xy_y:
            print('不在方位列表之中。')

        home[int(X)*int(Y)]=k

if __name__=='__main__':
    main()
亲测可行
#4
风卷浪起2024-02-24 20:51
能给个具体的演示吗,或者讲讲这是什么游戏
#5
是刘啊2024-04-24 19:29
这个游戏是怎么玩的?
#6
zbh1203072024-04-25 20:42
还是有bug
输出如下:
玩法:x*y得出位置,方块类型是符号,但必须是一个字节的。
玩耍之初,推荐一个方块类型呗!9
符合要求,谢谢推荐!
# # # # # # # # #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
# # # # # # # # #

方块类型:8 5
只输入一个字节的数!
# # # # # # # # #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
# # # # # # # # #

方块类型:8
选择方位x:1
选择方位y:1
# 8 # # # # # # #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
#               #
# # # # # # # # #

方块类型:
1