Last active
January 21, 2019 00:10
-
-
Save ibebrett/30bc95316afd89a39092f1112d440c82 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) | |
BLUE = (255, 0, 0) | |
# set up pygame | |
pygame.init() | |
# set up the window | |
windowSurface = pygame.display.set_mode((500, 400), 0, 32) | |
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() | |
# 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