Hello, I am currently doing an assignment for class and can't seem to be getting my code to work.
The objective of this assignment is to repeatedly draw rectangles on the screen that are each smaller than the last one by 10 pixels and are also 10 pixels apart. It is supposed to repeat until the squares are too small.
Yes, I know that pygame is not imported properly. This is just a recreation on my personal computer, my actual code is at school.
I believe I did something wrong with drawing the rectangle as the error says 'rect is not defined'. I'm new to coding so this is probably a really simple mistake that is easily fixed.
Any feedback would be appreciated. Thank you!
Here is the code in text format:
import pygame
from pygame.locals import *
def drawSquares(window):
# Create variables to keep track of size and position
size = 100
position = 0
# Use a loop to draw squares until the size is too small
while (size>0):
pygame.draw.rect(window,(0,0,255),position, position, size, size)
size -= 10
position += size+10