Example #1
0
    def __init__(self, canvas, color, type):        # initialization
        Brick_Data.__init__(self, color, type)
        self.shape = 0
        self.x = 0
        self.y = self.length
        self.canvas = canvas
        self.brick = list()
        self.pos = range(4)

        for j in range(0, self.canvas.winfo_height() / 20 + 1):
            self.board[0][j] = 1
            self.board[self.canvas.winfo_width() / 20 + 1][j] = 1
        for i in range(0, self.canvas.winfo_width() / 20 + 2):
            self.board[i][self.canvas.winfo_height() / 20 + 1] = 1
            self.board[i][self.canvas.winfo_height() / 20 + 2] = 1
            self.board[i][self.canvas.winfo_height() / 20 + 3] = 1
        self.stop_bottom = False   # whether the brick is at the bottom
        self.stop_left = False
        self.stop_right = False

        for i in range(0, 7):
            self.brick.insert(i, list())
        for i in range(0, 4):
            # pre-draw the brick
            self.brick[self.type].insert(i, self.canvas.create_rectangle(self.brick_type[self.type][self.shape][i * 2] * self.length, self.brick_type[self.type][self.shape][i * 2 + 1] * self.length, (self.brick_type[self.type][self.shape][i * 2] + 1) * self.length, (self.brick_type[self.type][self.shape][i * 2 + 1] + 1) * self.length, fill = self.color, width = 2))
            self.canvas.move(self.brick[self.type][i], self.canvas.winfo_width() / 2, -self.length)
Example #2
0
 def __init__(self, canvas, color, type):
     Brick_Data.__init__(self, color, type)
     self.canvas = canvas
     self.brick = [0 for i in range(4)]