Last active
January 16, 2021 18:07
-
-
Save dlebauer/29e6b61626a862f6df01cb138c0df333 to your computer and use it in GitHub Desktop.
Pyzero implementation of the purple shaker guy from scratch
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
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() |
Author
dlebauer
commented
Jan 16, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment