56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
import pygame
|
|
import sys
|
|
import game
|
|
|
|
pygame.init()
|
|
win = pygame.display.set_mode((500, 500))
|
|
|
|
clock = pygame.time.Clock()
|
|
|
|
# Farben
|
|
white = (255, 255, 255)
|
|
black = (0, 0, 0)
|
|
gray = (128, 128, 128)
|
|
|
|
# Rechtecke
|
|
start_button = pygame.Rect(100, 100, 100, 50)
|
|
quit_button = pygame.Rect(300, 100, 120, 50)
|
|
|
|
# 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
|
|
if start_button.collidepoint(mouse_pos) or \
|
|
start_text.get_rect(center=(start_button.x + 50, start_button.y + 25)).collidepoint(mouse_pos):
|
|
game.start()
|
|
|
|
# Beenden-Button
|
|
if quit_button.collidepoint(mouse_pos) or \
|
|
quit_text.get_rect(center=(quit_button.x + 60, quit_button.y + 25)).collidepoint(mouse_pos):
|
|
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))
|
|
|
|
clock.tick(60)
|
|
pygame.display.update() |