From 1971b72419726e9af080c432c704601e3f51b99e Mon Sep 17 00:00:00 2001 From: Megamichi Date: Fri, 23 Feb 2024 16:55:55 +0100 Subject: [PATCH] mehr verbessert bug ist immernochd a --- main.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index 722af6a..f702255 100644 --- a/main.py +++ b/main.py @@ -26,10 +26,10 @@ def draw_feld(feld,color_key,block_size): for b in range(len(feld)): if feld[b][a] != " ": pygame.draw.rect(screen,color_key[feld[b][a]], - (a*block_size[0], - b*block_size[1], - (block_size[0]), - (block_size[1]))) + (a*block_size, + b*block_size, + block_size, + block_size)) def get_block_size(): return 20,20 def get_meightboars(feld,position): @@ -51,16 +51,15 @@ def verarbeite_feld(feld): bellowr = feld2[(y+1)%feldy][(x+1)%feldx] bellowl = feld2[(y+1)%feldy][(x-1)%feldx] direction = random.choice([-1, 1]) # Zufällige Auswahl der Richtung - if bellow == " " and not bellow == "#": feld2[y][x] = feld[(y+1)%feldy][x] feld2[(y+1)%feldy][x] = feld[y][x] - elif bellowr == " " and not bellow == "#": + elif bellowr == " " and not bellowr == "#": feld2[y][x] = feld[(y+1)%feldy][(x+direction)%feldx] feld2[(y+1)%feldy][(x+direction)%feldx] = feld[y][x] - - elif bellowl == " " and not bellow == "#": + + elif bellowl == " " and not bellowl == "#": feld2[y][x] = feld[(y+1)%feldy][(x+direction)%feldx] feld2[(y+1)%feldy][(x+direction)%feldx] = feld[y][x] return feld2 @@ -91,7 +90,6 @@ wechselfarbe = "r" using_element = "a" pixelsize = 20 - show_debug = False running = True if __name__ == "__main__": @@ -103,18 +101,23 @@ if __name__ == "__main__": exit() if pressed_keys[pygame.K_PLUS] and not preview_pressed_keys[pygame.K_PLUS]: pixelsize += 2 + feld,feldx,feldy = make_feld(pixelsize,display_mode) if pressed_keys[pygame.K_MINUS] and not preview_pressed_keys[pygame.K_MINUS]: pixelsize -= 2 + feld,feldx,feldy = make_feld(pixelsize,display_mode) if pressed_keys[pygame.K_d] and not preview_pressed_keys[pygame.K_d]: show_debug = not show_debug - if pressed_keys[pygame.K_RETURN] and not preview_pressed_keys[pygame.K_RETURN]: + if pressed_keys[pygame.K_SPACE] and not preview_pressed_keys[pygame.K_SPACE]: if using_element == "a": using_element = "#" else: using_element = "a" if pressed_keys[pygame.K_r] and not preview_pressed_keys[pygame.K_r]: + if display_mode == "border": + display_mode = "loop" + else: + display_mode = "border" feld,feldx,feldy = make_feld(pixelsize,display_mode) - print("reset") preview_pressed_keys = pressed_keys ## event managment @@ -143,7 +146,7 @@ if __name__ == "__main__": acolor = r,g,b color_key = {"#":(100,100,100), "a":acolor} - draw_feld(feld,color_key,(pixelsize,pixelsize)) + draw_feld(feld,color_key,pixelsize) mx,my = pygame.mouse.get_pos() mousepressed = pygame.mouse.get_pressed()[0] if mousepressed :