Learnmonkey Learnmonkey Logo
× Warning:

The tutorial you are reading is currently a work in-progress.

Drawing To The Window

Drawing

So far, our window is just an empty black screen, pretty boring, right? So, in this tutorial, we'll learn how to draw shapes to the screen and how to change the background color to make our windows look a little better!

Changing The Background Color

First of all, let's change our background color! To that, we can write, after

for event in pygame.event.get():
    if event.type == pygame.QUIT:
      run = False
      break
but in the while loop,
WIN.fill("blue")
and our game loop will now be
run = True
while run:
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      run = False
      break
  WIN.fill("blue")

Now, you might think that putting the WIN.fill in the while loop is strange, but if you think about it, it will actually make sense. For example, if we draw more stuff on the screen later, we will want to fill the screen to cover up the previous drawings. You'll understand later!