Last active
November 24, 2019 18:08
-
-
Save PandaWhoCodes/4d55021f347922f32793bb5e0a5ca452 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
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