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.

54 lignes
1.2 KiB

  1. import pgzrun
  2. TITLE = "Paf l'oiseau"
  3. WIDTH = 400
  4. HEIGHT = 708
  5. def on_mouse_down():
  6. print('Clic enfoncé souris !')
  7. titi.backupspeed = titi.speed
  8. titi2.backupspeed = titi2.speed
  9. titi.speed = 0
  10. titi2.speed = 0
  11. titi.x -= 50
  12. titi2.y -= 50
  13. def on_mouse_up():
  14. print('Clic souris !')
  15. titi.speed = titi.backupspeed+2
  16. titi2.speed = titi2.backupspeed+2
  17. def draw():
  18. screen.blit('background', (0, 0))
  19. titi.draw()
  20. titi2.draw()
  21. tube_sup.draw()
  22. tube_inf.draw()
  23. titi = Actor('bird1', (75, 350))
  24. titi2 = Actor('bird2', (75, 350))
  25. ecart = 140
  26. tube_sup = Actor('top', (300, 0))
  27. tube_inf = Actor('bottom', (300, tube_sup.height + ecart))
  28. def update():
  29. titi.x += titi.speed
  30. titi2.y += titi2.speed
  31. if titi.x > 400 :
  32. titi.x = 0
  33. if titi2.y > 708 :
  34. titi2.y = 0
  35. vitesse_defilement = 1
  36. tube_sup.x -= vitesse_defilement
  37. tube_inf.x -= vitesse_defilement
  38. if tube_sup.x + tube_sup.width/2< 0 :
  39. tube_sup.x = WIDTH + tube_sup.width/2
  40. tube_inf.x = WIDTH + tube_sup.width/2
  41. if tube_sup.x < 0 :
  42. tube_sup.x = WIDTH
  43. titi.speed = 1
  44. titi2.speed = 1
  45. pgzrun.go()
  46. print(tube_sup.width, tube_sup.height)
  47. vitesse_defilement = 1