Created
January 21, 2019 00:33
-
-
Save ibebrett/39a58c5d69d046475e0f4a7a48bea9de to your computer and use it in GitHub Desktop.
This file contains 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 pygame, sys | |
WHITE = (255, 255, 255, 0) | |
BLUE = (255, 0, 0, 0) | |
# set up pygame | |
pygame.init() | |
# set up the window | |
windowSurface = pygame.display.set_mode((500, 400)) | |
pygame.display.set_caption('Hello world!') | |
y = 100 | |
x = 300 | |
# run the game loop | |
while True: | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: | |
pygame.quit() | |
sys.exit() | |
if event.type == pygame.KEYDOWN: | |
if event.key == pygame.K_UP: | |
y -= 5 | |
# draw the white background onto the surface | |
windowSurface.fill(WHITE) | |
# draw a blue circle onto the surface | |
pygame.draw.circle(windowSurface, BLUE, (x, y), 20, 0) | |
# draw the window onto the screen | |
pygame.display.update() | |
pygame.display.flip() | |
# wait a little bit | |
pygame.time.delay(16) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment