Un génie rebondissant dans un monde oriental
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

3 lat temu
1234567891011121314151617181920212223242526272829303132
  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()