Exemplo n.º 1
0
 def __init__(self):
     self.stats = Statistics()
     self.mixer = Mixer()
     self.particles = Particles()
     self.ship = Ship()
     self.bullets = []
     self.asteroids = []
     self.saucers = []
     self.explosions = []
     self.stars = []
     self.time_to_level = 0
     self.saucer_elapsed = 0
Exemplo n.º 2
0
    def render(self, gfx):

        # Score
        font = pygame.font.SysFont("OCR A Extended", 16)
        label = font.render(repr(self.score), 1, (255, 255, 255))
        gfx.blit(label, (10, 10))

        # Ships
        for i in range(self.ships):
            ship = Ship()
            ship.pos.x = (i * 16) + 14
            ship.pos.y = 40
            ship.scale(0.75)
            ship.update()
            ship.render(gfx)
Exemplo n.º 3
0
    def new_game(self):

        self.stars = []
        sec = Dimension(ScreenSize.width / 8, ScreenSize.height / 5)
        for x in xrange(8):
            for y in xrange(5):
                bounds = Rectangle(x * sec.width, y * sec.height, sec.width,
                                   sec.height)
                self.stars.append(Star(bounds))

        self.stats = Statistics()
        self.asteroids = []
        self.saucers = []
        self.bullets = []
        self.ship = Ship()
        self.saucer_elapsed = 0
        self.next_level()
Exemplo n.º 4
0
    def start(self):
        self.isRunning = True
        ship: Ship = Ship((200, 200), Colors.BLUE500.value)

        while self.isRunning:
            deltaTime = self.tick()

            # Update Game Objects
            ship.update(deltaTime)

            # Draw Game Objects
            self.screen.fill(Colors.BLACK.value)
            ship.draw(self.screen)
            display.update()

            for currentEvent in event.get():
                if currentEvent.type == QUIT:
                    self.stop()