Skip to content

Instantly share code, notes, and snippets.

@dlebauer
Created October 31, 2020 17:37
Show Gist options
  • Save dlebauer/ca32c91f1b87aede8e04c4d73e656fbd to your computer and use it in GitHub Desktop.
Save dlebauer/ca32c91f1b87aede8e04c4d73e656fbd to your computer and use it in GitHub Desktop.
# 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