2023-03-27 08:58:12 +02:00
|
|
|
import pygame
|
|
|
|
import sys
|
|
|
|
import game
|
|
|
|
|
|
|
|
pygame.init()
|
|
|
|
win = pygame.display.set_mode((500, 500))
|
|
|
|
|
2023-03-31 11:54:10 +02:00
|
|
|
clock = pygame.time.Clock()
|
|
|
|
|
2023-03-27 08:58:12 +02:00
|
|
|
# Farben
|
|
|
|
white = (255, 255, 255)
|
|
|
|
black = (0, 0, 0)
|
|
|
|
gray = (128, 128, 128)
|
|
|
|
|
|
|
|
# Rechtecke
|
|
|
|
start_button = pygame.Rect(100, 100, 100, 50)
|
2023-04-27 13:21:11 +02:00
|
|
|
quit_button = pygame.Rect(300, 100, 120, 50)
|
2023-03-27 08:58:12 +02:00
|
|
|
|
|
|
|
# Schriftart
|
|
|
|
font = pygame.font.Font(None, 32)
|
|
|
|
|
|
|
|
# Text
|
|
|
|
start_text = font.render("Start", True, black)
|
|
|
|
quit_text = font.render("Beenden", True, black)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
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-03-27 08:58:12 +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-03-27 08:58:12 +02:00
|
|
|
pygame.quit()
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
# Hintergrundfarbe
|
|
|
|
win.fill(white)
|
|
|
|
|
|
|
|
# Buttons zeichnen
|
|
|
|
pygame.draw.rect(win, gray, start_button)
|
|
|
|
win.blit(start_text, (start_button.x + 25, start_button.y + 10))
|
|
|
|
|
|
|
|
pygame.draw.rect(win, gray, quit_button)
|
|
|
|
win.blit(quit_text, (quit_button.x + 10, quit_button.y + 10))
|
|
|
|
|
2023-03-31 11:54:10 +02:00
|
|
|
clock.tick(60)
|
2023-03-27 08:58:12 +02:00
|
|
|
pygame.display.update()
|