def render(self, surface): heart_x = settings.VIRTUAL_WIDTH - 120 i = 0 # Draw filled hearts while i < self.lives: surface.blit(settings.GAME_TEXTURES['hearts'], (heart_x, 5), settings.GAME_FRAMES['hearts'][0]) heart_x += 11 i += 1 # Draw empty hearts while i < 3: surface.blit(settings.GAME_TEXTURES['hearts'], (heart_x, 5), settings.GAME_FRAMES['hearts'][1]) heart_x += 11 i += 1 render_text(surface, f'Score: {self.score}', settings.GAME_FONTS['tiny'], settings.VIRTUAL_WIDTH - 80, 5, (255, 255, 255)) for brick in self.bricks: brick.render(surface) self.paddle.render(surface) for ball in self.balls: ball.render(surface) for powerup in self.powerups: powerup.render(surface)
def render(self, surface): render_text(surface, 'High Scores', settings.GAME_FONTS['medium'], settings.VIRTUAL_WIDTH // 2, 20, (255, 255, 255), center=True) for i in range(settings.NUM_HIGHSCORES): name = '---' score = '---' if i < len(self.hs): item = self.hs[i] name = item[0] score = str(item[1]) render_text(surface, f'{i + 1}.', settings.GAME_FONTS['small'], settings.VIRTUAL_WIDTH // 2 - 60, 50 + i * 17, (255, 255, 255), center=True) render_text(surface, name, settings.GAME_FONTS['small'], settings.VIRTUAL_WIDTH // 2, 50 + i * 17, (255, 255, 255), center=True) render_text(surface, score, settings.GAME_FONTS['small'], settings.VIRTUAL_WIDTH // 2 + 60, 50 + i * 17, (255, 255, 255), center=True)
def render(self, surface): render_text(surface, f'Final score: {self.score}', settings.GAME_FONTS['medium'], settings.VIRTUAL_WIDTH // 2, settings.VIRTUAL_HEIGHT // 2 - 100, (255, 255, 255), center=True) render_text(surface, f'You are in the top {settings.NUM_HIGHSCORES}!', settings.GAME_FONTS['medium'], settings.VIRTUAL_WIDTH // 2, settings.VIRTUAL_HEIGHT // 2 - 70, (255, 255, 255), center=True) render_text(surface, 'Enter your name', settings.GAME_FONTS['small'], settings.VIRTUAL_WIDTH // 2, settings.VIRTUAL_HEIGHT // 2 - 20, (255, 255, 255), center=True) x = settings.VIRTUAL_WIDTH // 2 - 20 for i in range(3): color = (52, 235, 216) if self.selected == i else (255, 255, 255) render_text(surface, string.ascii_uppercase[self.name[i]], settings.GAME_FONTS['medium'], x, settings.VIRTUAL_HEIGHT // 2 + 10, color, center=True) x += 20 render_text(surface, 'Press Enter to finish!', settings.GAME_FONTS['small'], settings.VIRTUAL_WIDTH // 2, settings.VIRTUAL_HEIGHT - 50, (255, 255, 255), center=True)
def render(self, surface): render_text(surface, 'Select a paddle color with left and right', settings.GAME_FONTS['medium'], settings.VIRTUAL_WIDTH // 2, 20, (255, 255, 255), center=True) render_text(surface, 'Press Enter to continue!', settings.GAME_FONTS['medium'], settings.VIRTUAL_WIDTH // 2, 50, (255, 255, 255), center=True) self.paddle.render(surface) surface.blit(self.arrows_texture, (settings.VIRTUAL_WIDTH // 2 - 72 - 24, settings.VIRTUAL_HEIGHT - 68), settings.GAME_FRAMES['arrows'][0]) if self.paddle.skin == 0: pygame.draw.circle(self.gray_scale_surface, (40, 40, 40, 150), (12, 12), 12) surface.blit(self.gray_scale_surface, (settings.VIRTUAL_WIDTH // 2 - 72 - 24, settings.VIRTUAL_HEIGHT - 68)) surface.blit( self.arrows_texture, (settings.VIRTUAL_WIDTH // 2 + 72, settings.VIRTUAL_HEIGHT - 68), settings.GAME_FRAMES['arrows'][1]) if self.paddle.skin == 3: pygame.draw.circle(self.gray_scale_surface, (40, 40, 40, 150), (12, 12), 12) surface.blit(self.gray_scale_surface, (settings.VIRTUAL_WIDTH // 2 + 72, settings.VIRTUAL_HEIGHT - 68))
def render(self, surface): heart_x = settings.VIRTUAL_WIDTH-120 i = 0 # Draw filled hearts while i < self.lives: surface.blit( settings.GAME_TEXTURES['hearts'], (heart_x, 5), settings.GAME_FRAMES['hearts'][0] ) heart_x += 11 i += 1 # Draw empty hearts while i < 3: surface.blit( settings.GAME_TEXTURES['hearts'], (heart_x, 5), settings.GAME_FRAMES['hearts'][1] ) heart_x += 11 i += 1 render_text( surface, f'Score: {self.score}', settings.GAME_FONTS['tiny'], settings.VIRTUAL_WIDTH-80, 5, (255, 255, 255) ) for brick in self.bricks[0]: brick.render(surface) self.paddle.render(surface) self.ball.render(surface) render_text( surface, f'Level {self.level}', settings.GAME_FONTS['large'], settings.VIRTUAL_WIDTH//2, settings.VIRTUAL_HEIGHT//2-30, (255, 255, 255), center=True ) render_text( surface, 'Press Enter to serve!', settings.GAME_FONTS['medium'], settings.VIRTUAL_WIDTH//2, settings.VIRTUAL_HEIGHT//2, (255, 255, 255), center=True )
def render(self, surface): render_text(surface, 'Game Over', settings.GAME_FONTS['large'], settings.VIRTUAL_WIDTH // 2, settings.VIRTUAL_HEIGHT // 2 - 30, (255, 255, 255), center=True) render_text(surface, f'Final Score: {self.score}', settings.GAME_FONTS['medium'], settings.VIRTUAL_WIDTH // 2, settings.VIRTUAL_HEIGHT // 2, (255, 255, 255), center=True) render_text(surface, 'Press Enter!', settings.GAME_FONTS['medium'], settings.VIRTUAL_WIDTH // 2, settings.VIRTUAL_HEIGHT // 2 + 20, (255, 255, 255), center=True)
def render(self, surface): render_text( surface, 'Breakout', settings.GAME_FONTS['large'], settings.VIRTUAL_WIDTH//2, settings.VIRTUAL_HEIGHT//3, (255, 255, 255), center=True ) color = (52, 235, 216) if self.selected == 1 else (255, 255, 255) render_text( surface, 'Play Game', settings.GAME_FONTS['medium'], settings.VIRTUAL_WIDTH//2, settings.VIRTUAL_HEIGHT-60, color, center=True ) color = (52, 235, 216) if self.selected == 2 else (255, 255, 255) render_text( surface, 'High scores', settings.GAME_FONTS['medium'], settings.VIRTUAL_WIDTH//2, settings.VIRTUAL_HEIGHT-30, color, center=True )