Last active
August 15, 2017 16:36
-
-
Save deejaygraham/bbdb250302aa7ab958961fef930cb9e0 to your computer and use it in GitHub Desktop.
pygame showing a blue block
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 | |
pygame.init() | |
game_width = 640 | |
game_height = 480 | |
screen = pygame.display.set_mode((game_width, game_height)) # size must be (tuple) | |
pygame.display.set_caption('hello pygame') | |
# colours | |
black = (0, 0, 0) | |
blue = (0, 128, 255) | |
# box properties | |
box_width = 50 | |
box_height = 50 | |
box_left = 30 | |
box_top = 30 | |
box_colour = blue | |
done = False | |
while not done: | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: | |
done = True | |
screen.fill(black) | |
pygame.draw.rect(screen, box_colour, pygame.Rect(box_left, box_top, box_width, box_height)) | |
pygame.display.flip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment