Un petit jeu réalisé avec pgzero
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 regels
1.6 KiB

  1. import random
  2. import pgzrun
  3. TITLE = "Paf l'oiseau"
  4. WIDTH = 400
  5. HEIGHT = 708
  6. titi = Actor('bird1', (75, 350))
  7. titi.speed = 1
  8. ecart = 140
  9. tube_superieur = Actor('top', (300, 0))
  10. tube_inferieur = Actor('bottom', (300, tube_superieur.height + ecart))
  11. vitesse_defilement = 2
  12. gravite = 0.3
  13. fond = Actor('background', (200,350))
  14. fond2 = Actor('background', (-200,350))
  15. def draw():
  16. fond.draw()
  17. fond2.draw()
  18. tube_superieur.draw()
  19. tube_inferieur.draw()
  20. titi.draw()
  21. def on_mouse_down():
  22. print('Clic souris !')
  23. titi.y -= 30
  24. def reset():
  25. print("Retour au départ...")
  26. titi.speed = 1
  27. titi.center = (75, 350)
  28. tube_superieur.center = (300, 0)
  29. tube_inferieur.center = (300, tube_superieur.height + ecart)
  30. titi.image = "bird1"
  31. def heurte_tube() :
  32. print ("Paf !")
  33. titi.image = "birddead" # (oiseau mort)
  34. if titi.y < 700 :
  35. titi.y += 5
  36. def update():
  37. fond.x += 1
  38. fond2.x += 1
  39. if fond.x > 400 :
  40. fond.x = 200
  41. if fond2.x > 200 :
  42. fond2.x = 0
  43. titi.y += titi.speed
  44. tube_superieur.x -= vitesse_defilement
  45. tube_inferieur.x -= vitesse_defilement
  46. if tube_superieur.x + tube_superieur.width/2< 0 :
  47. tube_superieur.x = 400
  48. tube_inferieur.x = 400
  49. if (titi.colliderect(tube_superieur)) :
  50. heurte_tube()
  51. if (titi.colliderect(tube_inferieur)) :
  52. heurte_tube()
  53. if titi.y > HEIGHT :
  54. reset()
  55. if titi.y < 0 :
  56. reset()
  57. if (titi.colliderect(tube_inferieur)) :
  58. heurte_tube()
  59. #print(tube_superieur.width, tube_superieur.height)
  60. pgzrun.go()