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.

birdie.py 1.9 KiB

il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import pgzrun
  2. from random import randint
  3. # création fenêtre
  4. TITLE = "Paf l'oiseau" # définition titre
  5. WIDTH = 400 # largeur
  6. HEIGHT = 708 #hauteur
  7. def on_mouse_down(): # fonction 'click avec souris'
  8. print('Clique souris !') # sortie en terminal pour verifier si c'est ok
  9. titi.y -= 50
  10. titi.speed = 0
  11. #birdi.y -= 45
  12. # birdi.speed = 0
  13. def on_mouse_up(): # fonction 'quand la souris ne click plus'
  14. print('relache souris')
  15. titi.y += 6
  16. titi.speed += 3
  17. # birdi.y += 10
  18. # birdi.speed += 2
  19. def update():
  20. titi.y += titi.speed # mise a jour (60x/sec) de titi
  21. # birdi.y += birdi.speed
  22. tube_superieur.x -= tube_superieur.speed
  23. tube_inferieur.x -= tube_inferieur.speed
  24. if tube_superieur.x + tube_superieur.width/2 < 0 : # si la position en x du tube_superieur + la largeur du tube divisé par 2 vaut 0
  25. tube_superieur.x = WIDTH + tube_superieur.width/2 # alors la position en x du tube_superieur vaut la largeur de la fenetre + la largeur du tube divisée par 2
  26. tube_inferieur.x = WIDTH + tube_superieur.width/2 # alors la position en x du tube_inferieur vaut la largeur de la fenetre + la largeur du tube divisée par 2
  27. def draw():
  28. screen.blit('background', (0, 0)) # import arrière plan
  29. titi.draw() # 'dessiner' titi
  30. # birdi.draw()
  31. tube_inferieur.draw() # dessiner tuyau
  32. tube_superieur.draw()
  33. ecart = randint(110, 350)
  34. tube_superieur = Actor('top', (300, 0)) # ajouter tuyau et définir position
  35. tube_inferieur = Actor('bottom', (300, tube_superieur.height + ecart))
  36. tube_superieur.speed = 1
  37. tube_inferieur.speed = 1
  38. # birdi = Actor("bird2", (50, 250))
  39. # birdi.speed = 2
  40. titi = Actor('bird1', (75, 350)) # définir position de titi
  41. titi.speed = 3 # définir vitesses de chute de titi
  42. if titi.x > 400 : #and birdy.x > 400:
  43. titi.x = 2
  44. #birdi.x = 4
  45. pgzrun.go() # syntaxe 'conventionnelle' de pgzero