python - Random Tetris Shape -



python - Random Tetris Shape -

i trying write python programme draw random tetris shape onto board. here's code:

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 current_shape oan board self.current_shape = board.draw_shape(the_shape) def create_new_shape(self): ''' homecoming value: type: shape create random new shape centered @ y = 0 , x = int(self.board_width/2) homecoming 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) homecoming the_shape

my problem in "self.current_shape = board.draw_shape(the_shape). says the_shape not defined thought defined in create_new_shape.

you did variable the_shape local scope of function. when phone call create_new_shape() store result in field, should utilize reference shape:

self.current_shape = self.create_new_shape() # draw current_shape oan board self.current_shape = board.draw_shape(self.current_shape)

python tetris

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -