From 201c37d442439d0ae60d05976f3e9337bb1b3e46 Mon Sep 17 00:00:00 2001 From: Megamichi Date: Mon, 29 Jan 2024 19:19:45 +0100 Subject: [PATCH] aff --- main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 498f58c..cb4b563 100644 --- a/main.py +++ b/main.py @@ -64,12 +64,13 @@ boden = (screensize[1]//3)*2 player = Player() Kaktuse = [] +kaktus_ticker = 0 +next_kaktus = randint(100,500) for a in range(3): Kaktuse.append(Kaktus()) kaktusspeed = 5 show_debug = False running = True -kaktus_ticker = 0 if __name__ == "__main__": while running: ## key managment @@ -81,7 +82,6 @@ if __name__ == "__main__": show_debug = not show_debug if pressed_keys[pygame.K_SPACE] and not preview_pressed_keys[pygame.K_SPACE]: player.jump() - Kaktuse.append(Kaktus()) preview_pressed_keys = pressed_keys ## event managment @@ -97,7 +97,13 @@ if __name__ == "__main__": for a in Kaktuse: a.move(kaktusspeed) a.render() - kaktus_ticker += 1 + if a.pos[0] < 0: + Kaktuse.pop(0) + if kaktus_ticker > next_kaktus: + next_kaktus = randint(80,180) + kaktus_ticker =0 + Kaktuse.append(Kaktus()) + kaktus_ticker += kaktusspeed*0.3 if show_debug: get_debug_text() ## bildschirm aktuallisierung