Beispiel #1
0
    def __init__(self, size, ui):
        Ship.imageCache = Screen.imageCache
        Boulder.imageCache = Screen.imageCache
        BoulderFragment.imageCache = Screen.imageCache
        ScrollingCodeBackground.textCache = Screen.textCache
        ScrollingCodeBackground.resolution = Screen.resolution
        Counter.textCache = Screen.textCache
        Counter.resolution = Screen.resolution

        background = ScrollingCodeBackground()
        Screen.__init__(self, background, size, ui)

        self.ships = pygame.sprite.Group()
        ship = Ship(self,
                    pos=(size[0] / 2, size[1]),
                    screenBoundaries=(0, 0) + size)
        self.ships.add(ship)  #May change if we add more ships (multiplayer?)
        for ship in self.ships:
            ship.move((0, -ship.rect.height / 2))
            ship.targetPosition = ship.position

        self.boulders = pygame.sprite.Group()
        self.nextBoulderTime = 0

        self.boulderFragments = pygame.sprite.Group()

        self.healthBar = Bar(100,
                             int(size[0] * 0.72),
                             int(size[1] * 0.05),
                             fullColor=(255, 0, 0),
                             emptyColor=(0, 0, 0),
                             borderSize=int(size[1] * 0.005),
                             borderColor=(255, 255, 255))

        self.scoreDisplay = Counter(
            0, (self.healthBar.surface.get_rect().width, 0))

        musicPath = pathJoin(('music', 'Music.ogg'))
        pygame.mixer.music.load(musicPath)
        pygame.mixer.music.play(-1)