Jeux flappy bird en python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

63 lignes
1.1 KiB

  1. import pgzrun
  2. import random
  3. TITLE = "didi bird"
  4. WIDTH = 490
  5. HEIGHT = 490
  6. tb = Actor("bottom", midtop=(490, 350))
  7. th = Actor("top", midbottom=(490, 125))
  8. didi = Actor("bird1", (245, 245))
  9. end = 0
  10. gravitée = 2
  11. saut = -35
  12. gamemod_speed = -3
  13. flash = -30
  14. espassement = 1
  15. def draw():
  16. screen.blit("back", (0, 0))
  17. didi.draw()
  18. th.draw()
  19. tb.draw()
  20. def update():
  21. global end
  22. if didi.y == 475 and end == 0:
  23. print("--Game over--")
  24. end = 1
  25. if didi.y < 475 and end == 0:
  26. th.x += gamemod_speed
  27. tb.x += gamemod_speed
  28. if th.x <= 0:
  29. tb.x = 490
  30. tb.y = random.randrange(520,600)
  31. th.x = 490
  32. th.y = random.randrange(-160, -40)
  33. if didi.y <= 15:
  34. didi.y == 15
  35. if end == 0 and (didi.colliderect(tb) or didi.colliderect(th)):
  36. print("--Game over--")
  37. end = 1
  38. if didi.y < 475 and end == 0 :
  39. didi.y += gravitée
  40. def on_mouse_down(button):
  41. if button == mouse.LEFT:
  42. didi.y += saut
  43. elif button == mouse.RIGHT:
  44. th.x += flash
  45. tb.x += flash
  46. pgzrun.go()