Skip to content

Instantly share code, notes, and snippets.

@deejaygraham
Last active August 15, 2017 16:36
Show Gist options
  • Save deejaygraham/bbdb250302aa7ab958961fef930cb9e0 to your computer and use it in GitHub Desktop.
Save deejaygraham/bbdb250302aa7ab958961fef930cb9e0 to your computer and use it in GitHub Desktop.
pygame showing a blue block
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