Created
October 31, 2020 17:37
-
-
Save dlebauer/ca32c91f1b87aede8e04c4d73e656fbd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://pygame-zero.readthedocs.io/en/stable/introduction.html | |
import pgzrun | |
#import random | |
WIDTH = 500 | |
HEIGHT = 1000 | |
alien = Actor('alien') | |
alien.pos = WIDTH/2, HEIGHT/2 | |
def draw(): | |
screen.clear() | |
screen.fill((128, 0, 0)) | |
alien.draw() | |
def update(): | |
update_alien() | |
def update_alien(): | |
alien.y += 5 | |
if keyboard.left: | |
alien.x -= 5 | |
elif keyboard.right: | |
alien.x += 5 | |
if keyboard.up: | |
alien.y -= 5 | |
elif keyboard.down: | |
alien.y += 5 | |
# last line | |
pgzrun.go() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment