This commit is contained in:
Michael S. 2024-01-29 19:19:45 +01:00
parent c9413c4aff
commit 201c37d442

12
main.py
View file

@ -64,12 +64,13 @@ boden = (screensize[1]//3)*2
player = Player() player = Player()
Kaktuse = [] Kaktuse = []
kaktus_ticker = 0
next_kaktus = randint(100,500)
for a in range(3): for a in range(3):
Kaktuse.append(Kaktus()) Kaktuse.append(Kaktus())
kaktusspeed = 5 kaktusspeed = 5
show_debug = False show_debug = False
running = True running = True
kaktus_ticker = 0
if __name__ == "__main__": if __name__ == "__main__":
while running: while running:
## key managment ## key managment
@ -81,7 +82,6 @@ if __name__ == "__main__":
show_debug = not show_debug show_debug = not show_debug
if pressed_keys[pygame.K_SPACE] and not preview_pressed_keys[pygame.K_SPACE]: if pressed_keys[pygame.K_SPACE] and not preview_pressed_keys[pygame.K_SPACE]:
player.jump() player.jump()
Kaktuse.append(Kaktus())
preview_pressed_keys = pressed_keys preview_pressed_keys = pressed_keys
## event managment ## event managment
@ -97,7 +97,13 @@ if __name__ == "__main__":
for a in Kaktuse: for a in Kaktuse:
a.move(kaktusspeed) a.move(kaktusspeed)
a.render() 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: if show_debug:
get_debug_text() get_debug_text()
## bildschirm aktuallisierung ## bildschirm aktuallisierung