Esempio n. 1
0
 def __init__(self, x, y, width, height):
     self.grid = []
     self.pos = Point(x, y)
     self.origin = Point(0, 0)
     self.size = Dimension(width, height)
     self.rotState = rotState()
     self.tranState = tranState()
Esempio n. 2
0
    def render(self, gfx, gallery):
        
        gfx.blit(gallery.background, (0, 0))
        self.stats.render(gfx)
        
        # Render grid blocks
        for x in xrange(GridSize.width):
            for y in xrange(GridSize.height):
                if self.grid[x][y] > 0:
                    gallery.render_block(gfx, self.stats.level, self.grid[x][y] - 1, Point(x, y))
                elif self.grid[x][y] < 0:
                    gallery.render_ghost(gfx, (self.grid[x][y] * -1) - 1, Point(x, y))

        # Render next blocks
        for y in xrange(len(self.next_piece.grid)):
            for x in xrange(len(self.next_piece.grid[y])):
                if self.next_piece.grid[y][x]:
                    pt = Point(x - self.next_piece.origin.x, y - self.next_piece.origin.y)
                    gallery.render_next(gfx, self.stats.level, self.next_piece.grid[y][x] - 1, self.next_piece.size, pt)
Esempio n. 3
0
 def valid_move(self, piece):
     for y in xrange(len(piece.grid)):
         for x in xrange(len(piece.grid[y])):
             pt = Point(piece.pos.x + x, piece.pos.y + y)
             if piece.grid[y][x] and pt.y >= 0:
                 if pt.x < 0 or pt.x >= GridSize.width or pt.y >= GridSize.height:
                     return False
                 if self.grid[pt.x][pt.y]:
                     return False
     return True
Esempio n. 4
0
 def set(self, grid):
     self.grid = grid
     self.origin = Point(self.left(), self.top())
Esempio n. 5
0
 def __init__(self, x, y, width, height):
     self.grid = []
     self.pos = Point(x, y)
     self.origin = Point(0, 0)
     self.size = Dimension(width, height)
Esempio n. 6
0
 def next_to_pos(self, size, pt):
     center = Point((size.width * BlockSize.width) / 2, (size.height * BlockSize.height) / 2)
     offset = Point(411 - center.x, 84 - center.y)
     x = pt.x * BlockSize.width + offset.x
     y = pt.y * BlockSize.height + offset.y
     return Point(x, y)
Esempio n. 7
0
 def grid_to_pos(self, pt):
     x = pt.x * BlockSize.width + 140
     y = pt.y * BlockSize.height + 40
     return Point(x, y)