Un petit jeu réalisé avec pgzero
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.

65 lignes
1.2 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. saut = -7
  11. gravite = 0.2
  12. frotement = 1
  13. gamemod_speed = -3
  14. dash = 0
  15. espassement = 1
  16. def draw():
  17. screen.blit("back", (0, 0))
  18. didi.draw()
  19. th.draw()
  20. tb.draw()
  21. def update():
  22. global end, saut, gamemod_speed, dash
  23. if didi.y == 475 and end == 0:
  24. print("--Game over--")
  25. end = 1
  26. if didi.y < 475 and end == 0:
  27. th.x += gamemod_speed
  28. tb.x += gamemod_speed
  29. if th.x <= 0:
  30. tb.x = 490
  31. tb.y = random.randrange(520,600)
  32. th.x = 490
  33. th.y = random.randrange(-160, -40)
  34. if didi.y <= 15:
  35. didi.y == 15
  36. if end == 0 and (didi.colliderect(tb) or didi.colliderect(th)):
  37. print("--Game over--")
  38. end = 1
  39. if didi.y < 475 and end == 0 :
  40. didi.y += saut
  41. saut += gravite
  42. gamemod_speed += dash
  43. if dash < 0 and end == 0:
  44. dash += frotement
  45. def on_mouse_down(button):
  46. global saut, dash
  47. if button == mouse.LEFT:
  48. saut += -5
  49. elif button == mouse.RIGHT:
  50. dash += -1
  51. pgzrun.go()