Skip to content

Instantly share code, notes, and snippets.

@PandaWhoCodes
Last active November 24, 2019 18:08
Show Gist options
  • Save PandaWhoCodes/4d55021f347922f32793bb5e0a5ca452 to your computer and use it in GitHub Desktop.
Save PandaWhoCodes/4d55021f347922f32793bb5e0a5ca452 to your computer and use it in GitHub Desktop.
import pgzrun
from random import randint, choice
import string
WIDTH = 800
HEIGHT = 500
VELOCITY = 1
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
LETTER = {"letter": "", "x": 0, "y": 0}
def draw(): # Pygame Zero draw function
screen.clear()
screen.fill(BLACK)
screen.draw.text(LETTER["letter"], (LETTER["x"], LETTER["y"]), fontsize=50, color=WHITE)
def update(): # Pygame Zero update function
LETTER["y"] += VELOCITY
def on_key_down(key, mod, unicode):
if unicode:
if unicode == LETTER["letter"]:
update_letter()
def update_letter():
LETTER["letter"] = choice(string.ascii_letters).lower()
LETTER["x"] = randint(10, WIDTH)
LETTER["y"] = 1
update_letter()
pgzrun.go()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment