formatiert

This commit is contained in:
Michael S. 2024-02-23 17:31:58 +01:00
parent 1971b72419
commit e3078e876f

29
main.py
View file

@ -3,7 +3,10 @@ import pygame
import pygame.gfxdraw
import copy
import random
pygame.init()
## funktionen
def get_debug_text():
def text(text, line_counter):
@ -16,30 +19,40 @@ def get_debug_text():
text(f"{str(a)} = {str(globalvars[a])}", line_counter)
line_counter += 1
def centered_text(text=str, pos=tuple, color=tuple):
text = default_font.render(str(text), True, color, (255, 255, 255))
screen.blit(text, (pos[0] - text.get_width() / 2, pos[1]))
def draw_feld(feld, color_key, block_size):
# print(feld)
for a in range(len(feld[0])):
for b in range(len(feld)):
if feld[b][a] != " ":
pygame.draw.rect(screen,color_key[feld[b][a]],
(a*block_size,
b*block_size,
block_size,
block_size))
pygame.draw.rect(
screen,
color_key[feld[b][a]],
(a * block_size, b * block_size, block_size, block_size),
)
def get_block_size():
return 20, 20
def get_meightboars(feld, position):
nachtbaren = []
return nachtbaren
def save_list(liste, index1, index2):
if index2 > len(liste[0]) and index1 > len(liste):
return liste[index1][index2]
else:
return "a"
def verarbeite_feld(feld):
feld2 = copy.deepcopy(feld)
for y in range(len(feld)):
@ -64,6 +77,7 @@ def verarbeite_feld(feld):
feld2[(y + 1) % feldy][(x + direction) % feldx] = feld[y][x]
return feld2
def make_feld(size, mode):
x = screensize[0] // size
y = screensize[1] // size
@ -72,6 +86,8 @@ def make_feld(size,mode):
for x in range(x):
feld[y - 1][x] = "#"
return feld, x, y
## klassen
@ -144,8 +160,7 @@ if __name__ == "__main__":
if b == 0:
wechselfarbe = "r"
acolor = r, g, b
color_key = {"#":(100,100,100),
"a":acolor}
color_key = {"#": (100, 100, 100), "a": acolor}
draw_feld(feld, color_key, pixelsize)
mx, my = pygame.mouse.get_pos()
mousepressed = pygame.mouse.get_pressed()[0]