Drawing rectangles
Mentors' note:
Here we are giving them code to draw a rectangle on the display, tell them to try and change the color of the Rectangle, and then make them change the x parameter, y parameters, width and height of the rectangle
Then the goal is to make them create a rectangle on each corner and one in the center
In order to draw a rectangle we need to give python some parameters:
pygame.draw.rect(DISPLAY, Color('green'), Rect(0,0,50,100))
This will draw a green rectangle on our display, the rectangle is positionned at x:0 and y:0 and has 50 width and 100 height
It is important to understand how coordinates work, (0,0) is the top left, (300,0) is the top right, (0,300) is the bottom left and (300,300) is the bottom right. It is counted in pixels!
So when we create a
Rect(0,0,50,100)
We create a rectangle which is potitionned at the top left (0,0), has a width of 50 and a height of 100
[ ] Change the color, position and size of the rectangle and try to understand what you are changing
[ ] Create a rectangle on each corner
[ ] Create a rectangle in the center