Skip to content

Instantly share code, notes, and snippets.

@dlebauer
Last active January 16, 2021 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlebauer/29e6b61626a862f6df01cb138c0df333 to your computer and use it in GitHub Desktop.
Save dlebauer/29e6b61626a862f6df01cb138c0df333 to your computer and use it in GitHub Desktop.
Pyzero implementation of the purple shaker guy from scratch
import pgzrun
import time
import random
WIDTH = 400
HEIGHT = 400
guy = Actor("purple_guy")
guy.pos = (200, 200)
guy.angle = -25
def draw():
screen.clear()
screen.fill((45, 235, 57))
guy.draw()
def update():
global dir
if not dir:
dir = 'left'
if guy.angle <= -25:
dir = 'right'
if guy.angle >= 25:
dir = 'left'
if dir == 'left':
guy.angle -= random.randint(5, 10)
if dir == 'right':
guy.angle += random.randint(8, 13)
pgzrun.go()
@dlebauer
Copy link
Author

purple_guy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment