Ejemplo n.º 1
0
    def on_render(self):

        # Background rendering
        self.screen.blit(gfx.img_background, (0, 0))
        for _ in range(self.star_speed):
            self.stars.render()

        # Display game info
        score = self.font.render("ENEMIES KILLED: " + str(self.KILL_COUNT), True, WHITE)
        lives = [(SCREEN_WIDTH - (gfx.img_life.get_width() + 10),
                  SCREEN_HEIGHT - gfx.img_life.get_height() - 20),
                 (SCREEN_WIDTH - (gfx.img_life.get_width() + 10) * 2,
                  SCREEN_HEIGHT - gfx.img_life.get_height() - 20), (
                     SCREEN_WIDTH - (gfx.img_life.get_width() + 10) * 3,
                     SCREEN_HEIGHT - gfx.img_life.get_height() - 20)]
        for i in range(self.player_lives):
            self.screen.blit(gfx.img_life, lives[i])

        for boss in self.cruiser:
            boss.health_bar(self.screen)

        self.screen.blit(score, (20, SCREEN_HEIGHT - 50))

        if self.boss_defeated and self.player.rect.y < 100:
            i = 1 + i
            self.screen.fill((0,0,0,i))

        # Render each sprite
        self.all_sprites.draw(gfx.screen)

        # Draw screen (with scanline)
        helper_functions.scanlines()
        pg.display.flip()
Ejemplo n.º 2
0
    def title_screen(self):
        scroll = 0
        anim = 0
        ship_image = None

        while True:
            title_a = gfx.img_title_a
            title_b = gfx.img_title_b
            title_size = title_a.get_size()
            steps = int(title_size[0] / 2)
            for i in range(steps + 75):
                self.screen.blit(gfx.img_title_background, (0, 0))
                self.screen.blit(gfx.img_title_stars, (0, 100))
                self.screen.blit(title_a, (10 - title_size[0] + i * 2, 300))
                self.screen.blit(title_b, (10 + SCREEN_WIDTH - i * 2, 300))
                pg.display.flip()
            snd.load_sound("blow_up.wav")
            for i in range(100):
                pg.display.update(self.screen.fill(WHITE))
            self.screen.blit(gfx.img_title_background, (0, 0))
            snd.play_song("title_song.ogg")
            break

        while True:

            if scroll <= SCREEN_WIDTH:
                scroll += .5
            else:
                scroll = 0

            self.screen.blit(gfx.img_title_stars, (scroll, 100))
            self.screen.blit(gfx.img_title_stars, (-SCREEN_WIDTH + scroll, 100))
            self.screen.blit(gfx.img_title_whole, (SCREEN_CENTER[0] - gfx.img_title_whole.get_width() / 2 + 20, 300))

            for _ in range(1):
                if anim < 20:
                    ship_image = gfx.title_ship_a
                elif anim > 20:
                    ship_image = gfx.title_ship_b
                self.screen.blit(ship_image, (SCREEN_CENTER[0] - (gfx.title_ship_a.get_width() / 2) + 20, 600))

                if anim < 50:
                    menu = self.font.render("PRESS ENTER", True, WHITE)
                    self.screen.blit(menu, (SCREEN_CENTER[0] - menu.get_width() / 2, SCREEN_CENTER[1]))
                elif anim > 50:
                    menu = self.font.render("PRESS ENTER", True, BLACK)
                    self.screen.blit(menu, (SCREEN_CENTER[0] - menu.get_width() / 2, SCREEN_CENTER[1]))

            anim += 1
            if anim >= 100:
                anim = 0

            pg.display.update()

            e = pg.event.poll()
            if e.type == pg.KEYDOWN:
                if e.key == pg.K_RETURN:
                    snd.load_sound("takeoff.wav")
                    while True:
                        for i in range(255):
                            self.screen.fill((255 - i, 255 - i, 255 - i))
                            helper_functions.scanlines()
                            pg.display.update()
                        break
                    break

        while True:
            text = self.font.render("GET READY", True, WHITE)
            count_list = ["5", "4", "3", "2", "1", "GO!"]
            for i in range(6):
                countdown = self.font.render(count_list[i], True, WHITE)
                self.screen.fill(BLACK)
                self.screen.blit(text, (SCREEN_CENTER[0] - text.get_width() / 2, SCREEN_CENTER[1]))
                self.screen.blit(countdown, (SCREEN_CENTER[0] - countdown.get_width() / 2, SCREEN_CENTER[1] + 30))
                helper_functions.scanlines()
                pg.display.update()
                pg.time.wait(1000)
            break

        snd.play_song("saturns_folly.ogg")
        self.started = True