Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # All aliens are welcome in our Pygame Zero world!
- # Copyright 2021-2024 Roland Richter [Mu: Pygame Zero]
- # Create a window of size 800 x 500
- TITLE = "All aliens welcome!"
- WIDTH = 800
- HEIGHT = 500
- # TRY to use other images from from https://kenney.nl/assets/
- alien = Actor("alien.png", (WIDTH - 40, 140))
- def draw():
- # Find colour names at https://www.pygame.org/docs/ref/color_list.html
- screen.fill("skyblue2")
- screen.draw.filled_rect(Rect((0, 400), (WIDTH, HEIGHT - 400)), "springgreen3")
- # Draw the sun, and a cloud in the sky
- screen.draw.filled_circle((150, 70), 45, "yellow")
- screen.draw.filled_circle((0.75 * WIDTH, 0.30 * HEIGHT), 42, "white")
- screen.draw.filled_circle((0.72 * WIDTH, 0.31 * HEIGHT), 42, "white")
- screen.draw.filled_circle((0.77 * WIDTH, 0.28 * HEIGHT), 42, "white")
- screen.draw.filled_circle((0.79 * WIDTH, 0.32 * HEIGHT), 42, "white")
- # TRY to expand the landscape and draw more into it.
- # Draw the alien
- alien.draw()
- def update():
- # Move alien to the right; ...
- alien.x += 2
- # ... if the right edge is reached, re-start at the left.
- if alien.x > WIDTH:
- alien.x = 0
- # TRY to make the alien fly from right to left instead left to right
- # ----------------------------------------------------------------------
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <https://www.gnu.org/licenses/>.
Advertisement
Add Comment
Please, Sign In to add comment