File structure

This commit is contained in:
Finn-Luca Ortelbach
2026-03-12 14:25:45 +01:00
commit c44e2f433c
2 changed files with 73 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
from pygame import *
import random
init()
width, height = 1920, 1080
screen = display.set_mode((width, height))
display.set_caption("Game")
clock = time.Clock()
game_font = font.SysFont(None, 40)
white = (255,255,255)
blue = (0,0,255)
red = (255,0,0)
green = (0,255,0)
black = (0, 0, 0)
grey = (180, 180, 180)
speed = 10
p_x = 100
p_y = 200
p_size = 100
c_x = 600
c_y = 250
c_r = 100
running = True
while running:
for e in event.get():
if e.type == QUIT:
running = False
print("Programm closed by user input")
if e.type == MOUSEBUTTONDOWN:
m_x, m_y = mouse.get_pos()
dx = m_x - c_x
dy = m_y - c_y
# if dx * dx + dy*dy <= c_r * c_r:
# c_color = green if c_color == red else red
keys = key.get_pressed()
if keys[K_LEFT]:
p_x -= speed
if keys[K_RIGHT]:
p_x += speed
if keys[K_DOWN]:
p_y += speed
if keys[K_UP]:
p_y -= speed
if keys[K_a]:
c_x -= speed
if keys[K_d]:
c_x += speed
if keys[K_s]:
c_y += speed
if keys[K_w]:
c_y -= speed
screen.fill(white)
draw.rect(screen, blue, (p_x, p_y, p_size, p_size))
draw.rect(screen, green, (c_x, c_y, p_size, p_size))
display.flip()
clock.tick(60)
quit()