python做俄罗斯方块如何显示下一个随机方块_随机俄罗斯方块形状
我正在嘗試編寫一個python程序,它將在一塊板上繪制一個隨機的俄羅斯方塊形狀。
我的代碼是:def __init__(self, win):
self.board = Board(win, self.BOARD_WIDTH, self.BOARD_HEIGHT)
self.win = win
self.delay = 1000
self.current_shape = self.create_new_shape()
# Draw the current_shape oan the board
self.current_shape = Board.draw_shape(the_shape)
def create_new_shape(self):
''' Return value: type: Shape
Create a random new shape that is centered
at y = 0 and x = int(self.BOARD_WIDTH/2)
return the shape
'''
y = 0
x = int(self.BOARD_WIDTH/2)
self.shapes = [O_shape,
T_shape,
L_shape,
J_shape,
Z_shape,
S_shape,
I_shape]
the_shape = random.choice(self.shapes)
return the_shape
我的問題是“自電流形狀= Board.draw_形狀(_形)。它說沒有定義_形狀,但我想我是在create_new_形狀中定義的。在
總結(jié)
以上是生活随笔為你收集整理的python做俄罗斯方块如何显示下一个随机方块_随机俄罗斯方块形状的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: win10远程控制centos7.0开机
- 下一篇: 如何查看tensorflow源代码