Un génie rebondissant dans un monde oriental
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.

33 lignes
857 B

  1. import pgzrun
  2. from pgzero.builtins import Actor
  3. TITLE = 'Aladdin'
  4. WIDTH = 686
  5. HEIGHT = 490
  6. genius = Actor('genie', midtop=(343, 245))
  7. genius.x_direction = 1 # right
  8. genius.y_direction = 1 # down
  9. genius.speed = 2
  10. def update():
  11. if genius.x+genius.width/2 >= WIDTH and genius.x_direction == 1:
  12. genius.x_direction = -1
  13. if genius.x-genius.width/2 <= 0 and genius.x_direction == -1:
  14. genius.x_direction = 1
  15. if genius.y+genius.height/2 >= HEIGHT and genius.y_direction == 1:
  16. genius.y_direction = -1
  17. if genius.y-genius.height/2 <= 0 and genius.y_direction == -1:
  18. genius.y_direction = 1
  19. genius.x += genius.x_direction * genius.speed
  20. genius.y += genius.y_direction * genius.speed
  21. def draw():
  22. screen.blit('background', (0, 0))
  23. genius.draw()
  24. pgzrun.go()