parent
3e744f8147
commit
6186cc0751
|
After Width: | Height: | Size: 2.9 MiB |
@ -0,0 +1,52 @@
|
||||
import pygame
|
||||
import settings
|
||||
from settings import MyColors
|
||||
|
||||
class Endscreen:
|
||||
def __init__(self, screen, score):
|
||||
self.screen = screen
|
||||
self.score = score
|
||||
self.background = pygame.image.load(settings.BACKGROUND_IMG_COMP).convert_alpha()
|
||||
self.font = pygame.font.Font(settings.fonts.PressStart2P, 60)
|
||||
self.small_font = pygame.font.Font(settings.fonts.PressStart2P, 24)
|
||||
|
||||
self.retry_button = pygame.Rect(390, 400, 200, 50)
|
||||
self.menu_button = pygame.Rect(690, 400, 200, 50)
|
||||
|
||||
def draw(self):
|
||||
self.screen.blit(self.background, (0, 0))
|
||||
|
||||
# Score-Text
|
||||
score_text = self.font.render(f"Dein Score: {self.score}", True, (255, 255, 255)) # z.B. Gold
|
||||
self.screen.blit(score_text, (settings.SCREEN_WIDTH // 2 - score_text.get_width() // 2, 200))
|
||||
|
||||
pygame.draw.rect(self.screen, MyColors.yellow, self.retry_button)
|
||||
pygame.draw.rect(self.screen, MyColors.yellow, self.menu_button)
|
||||
|
||||
nochmal_text = self.small_font.render("Nochmal", True, MyColors.brown)
|
||||
menu_text = self.small_font.render("Menü", True, MyColors.brown)
|
||||
|
||||
self.screen.blit(nochmal_text, (self.retry_button.x + 20, self.retry_button.y + 10))
|
||||
self.screen.blit(menu_text, (self.menu_button.x + 35, self.menu_button.y + 10))
|
||||
|
||||
return self.retry_button, self.menu_button
|
||||
|
||||
def handle_event(self, event):
|
||||
|
||||
joysticks = [pygame.joystick.Joystick(x) for x in range(pygame.joystick.get_count())]
|
||||
|
||||
# Controller-Eingaben prüfen
|
||||
retry_controller_action = False
|
||||
menu_controller_action = False
|
||||
for joystick in joysticks:
|
||||
if joystick.get_button(2):
|
||||
retry_controller_action = True
|
||||
if joystick.get_button(3):
|
||||
menu_controller_action = True
|
||||
|
||||
if event.type == pygame.MOUSEBUTTONDOWN:
|
||||
if self.retry_button.collidepoint(event.pos):
|
||||
return "retry"
|
||||
elif self.menu_button.collidepoint(event.pos):
|
||||
return "menu"
|
||||
return None
|
||||
Loading…
Reference in new issue