# fooling around with pygame --> draw/fill some rectangles
import pygame as pg
# initiate pygame first
pg.init()
#create a 400x300 window
screen = pg.display.set_mode((400, 300))
# give it a title
pg.display.set_caption('Draw/fill rectangles using pygame')
# some color constants
white = 0xFFFFFF
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF
yellow = 0xFFFF00
#draw/fill a 77x33 rectangle in position x=250, y=50 (NW corner)
screen.fill(white, (250, 50, 77, 33))
# more rectangles, vary color, size, position ...
screen.fill(red, (30, 20, 70, 120))
screen.fill(red, (140, 70, 90, 80))
screen.fill(green, (150, 80, 70, 60))
screen.fill(yellow, (200, 170, 150, 60))
screen.fill(blue, (70, 200, 100, 70))
# hey, nothing gets displayed until one updates the screen
pg.display.update()
# create the event loop to get things going
# and specify an exit action (clicking on the window x)
while True:
for event in pg.event.get():
if event.type == pg.QUIT:
raise SystemExit