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.

51 line
1.1 KiB

  1. import pgzrun
  2. TITLE = "Paf l'oiseau"
  3. WIDTH = 400
  4. HEIGHT = 708
  5. def on_mouse_down(button):
  6. if button == mouse.LEFT:
  7. print('freinage')
  8. titi.speed -= 1
  9. elif button == mouse.RIGHT:
  10. print('accélaration')
  11. titi.speed += 1
  12. def on_mouse_up():
  13. titi.speed = 1
  14. blackbird.speed = 1
  15. def update():
  16. if titi.left > WIDTH:
  17. titi.right = 0
  18. if titi.right < 0:
  19. titi.left = WIDTH
  20. titi.x += titi.speed
  21. if tube_superieur.left > WIDTH:
  22. tube_superieur.right = 0
  23. if tube_inferieur.right < 0:
  24. tube_inferieur.left = WIDTH
  25. tube_superieur.x += vitesse_defilement
  26. tube_inferieur.x += vitesse_defilement
  27. def draw():
  28. screen.blit('background', (0, 0))
  29. titi.draw()
  30. blackbird.draw()
  31. tube_superieur.draw()
  32. tube_inferieur.draw()
  33. titi = Actor('bird1', (75, 350))
  34. blackbird = Actor('bird2', (95, 150))
  35. ecart = 140
  36. tube_superieur = Actor('top', (300, 0))
  37. tube_inferieur = Actor('bottom', (300, tube_superieur.height + ecart))
  38. titi.speed = 1
  39. blackbird.speed = 2
  40. vitesse_defilement = 1
  41. print(tube_superieur.width, tube_superieur.height)
  42. pgzrun.go()