예제 #1
0
    def __init__(self, screen, blocksize, position=(0, 0)):
        """Initialize main panel"""
        pygame.sprite.Sprite.__init__(self)

        self.blocksize = blocksize
        self.width = blocksize * 16
        self.height = blocksize * 21

        self.image = pygame.Surface((self.width, self.height))
        self.image.fill((255, 255, 255))

        self.rect = self.image.get_rect()
        self.rect.topleft = position

        # LShape, RShape, SShape, ZShape, TShape, SquareShape, StraightShape
        self.shapes = [
            LShape, RShape, SShape, TShape, SquareShape, StraightShape, ZShape
        ]

        self.linechecker = LineChecker(self.blocksize)

        self.screen = screen
        self.background = pygame.Surface.convert(
            pygame.image.load(os.path.join("data", "background1.png")))
예제 #2
0
    def __init__(self, blocksize=25):
        """Initialize"""
        pygame.mixer.pre_init(44100, -16, 2, 1024)
        pygame.init()

        self.width = 16 * blocksize
        self.height = 21 * blocksize
        self.blocksize = blocksize

        self.linechecker = LineChecker(self.blocksize)

        # LShape, RShape, SShape, ZShape, TShape, SquareShape, StraightShape
        self.shapes = [
            LShape, RShape, SShape, TShape, SquareShape, StraightShape, ZShape
        ]

        self.screen = pygame.display.set_mode((self.width, self.height))
        pygame.display.set_caption("Keltris")

        self.background = pygame.Surface.convert(
            pygame.image.load(os.path.join("data", "background.png")))

        self.update_time = 0
        self.paused = False