rric

aliens_welcome

Apr 29th, 2024 (edited)
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.98 KB | None | 0 0
  1. # All aliens are welcome in our Pygame Zero world!
  2. # Copyright 2021-2024 Roland Richter                  [Mu: Pygame Zero]
  3.  
  4. # Create a window of size 800 x 500
  5. TITLE = "All aliens welcome!"
  6. WIDTH = 800
  7. HEIGHT = 500
  8.  
  9. # TRY to use other images from from https://kenney.nl/assets/
  10. alien = Actor("alien.png", (WIDTH - 40, 140))
  11.  
  12. def draw():
  13.     # Find colour names at https://www.pygame.org/docs/ref/color_list.html
  14.     screen.fill("skyblue2")
  15.     screen.draw.filled_rect(Rect((0, 400), (WIDTH, HEIGHT - 400)), "springgreen3")
  16.  
  17.     # Draw the sun, and a cloud in the sky
  18.     screen.draw.filled_circle((150, 70), 45, "yellow")
  19.     screen.draw.filled_circle((0.75 * WIDTH, 0.30 * HEIGHT), 42, "white")
  20.     screen.draw.filled_circle((0.72 * WIDTH, 0.31 * HEIGHT), 42, "white")
  21.     screen.draw.filled_circle((0.77 * WIDTH, 0.28 * HEIGHT), 42, "white")
  22.     screen.draw.filled_circle((0.79 * WIDTH, 0.32 * HEIGHT), 42, "white")
  23.  
  24.     # TRY to expand the landscape and draw more into it.
  25.  
  26.     # Draw the alien
  27.     alien.draw()
  28.  
  29.  
  30. def update():
  31.     # Move alien to the right; ...
  32.     alien.x += 2
  33.     # ... if the right edge is reached, re-start at the left.
  34.     if alien.x > WIDTH:
  35.         alien.x = 0
  36.  
  37.     # TRY to make the alien fly from right to left instead left to right
  38.    
  39.  
  40. # ----------------------------------------------------------------------
  41. # This program is free software: you can redistribute it and/or modify
  42. # it under the terms of the GNU General Public License as published by
  43. # the Free Software Foundation, either version 3 of the License, or
  44. # (at your option) any later version.
  45. #
  46. # This program is distributed in the hope that it will be useful,
  47. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  48. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  49. # GNU General Public License for more details.
  50. #
  51. # You should have received a copy of the GNU General Public License
  52. # along with this program.  If not, see <https://www.gnu.org/licenses/>.
  53.  
Advertisement
Add Comment
Please, Sign In to add comment