2023-04-27 13:21:11 +02:00
|
|
|
import pygame
|
|
|
|
import game
|
2023-04-27 13:30:17 +02:00
|
|
|
import sys
|
2023-04-27 13:21:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
class GameOver(pygame.sprite.Sprite):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
self.label = pygame.font.SysFont("Arial", 50).render("Game Over", True, (255, 0, 0))
|
|
|
|
self.rect = self.label.get_rect(center=(400, 300))
|
|
|
|
|
|
|
|
def draw(self, win):
|
2023-04-27 14:28:31 +02:00
|
|
|
win.fill((0, 0, 0)) # Black
|
|
|
|
win.blit(self.label, self.rect)
|
|
|
|
|
|
|
|
self.start_quit(win)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def start_quit(win):
|
2023-04-27 13:21:11 +02:00
|
|
|
# Rechtecke
|
|
|
|
start_button = pygame.Rect(200, 400, 100, 50)
|
|
|
|
quit_button = pygame.Rect(500, 400, 120, 50)
|
|
|
|
# Schriftart
|
|
|
|
font = pygame.font.Font(None, 32)
|
|
|
|
# Text
|
|
|
|
start_text = font.render("Start", True, (0, 0, 0))
|
|
|
|
quit_text = font.render("Beenden", True, (0, 0, 0))
|
|
|
|
# Buttons zeichnen
|
|
|
|
pygame.draw.rect(win, (100, 100, 100), start_button)
|
|
|
|
win.blit(start_text, (start_button.x + 25, start_button.y + 10))
|
|
|
|
pygame.draw.rect(win, (100, 100, 100), quit_button)
|
|
|
|
win.blit(quit_text, (quit_button.x + 10, quit_button.y + 10))
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
pygame.quit()
|
|
|
|
sys.exit()
|
|
|
|
if event.type == pygame.MOUSEBUTTONDOWN:
|
|
|
|
mouse_pos = event.pos
|
|
|
|
|
|
|
|
# Start-Button
|
2023-04-27 14:28:31 +02:00
|
|
|
if start_button.collidepoint(mouse_pos) or \
|
|
|
|
start_text.get_rect(center=(start_button.x + 50, start_button.y + 25)).collidepoint(mouse_pos):
|
2023-04-27 13:21:11 +02:00
|
|
|
game.start()
|
|
|
|
|
|
|
|
# Beenden-Button
|
2023-04-27 14:28:31 +02:00
|
|
|
if quit_button.collidepoint(mouse_pos) or \
|
|
|
|
quit_text.get_rect(center=(quit_button.x + 60, quit_button.y + 25)).collidepoint(mouse_pos):
|
2023-04-27 13:21:11 +02:00
|
|
|
pygame.quit()
|
|
|
|
sys.exit()
|