import pygame, sys
pygame.init()
screen=pygame.display.set_mode([640, 480])
screen.fill([255, 255, 255])
pygame.draw.rect(screen, [255, 0, 0], [250, 150, 300, 200] 0)
pygame.display.flip()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
And when you run it, you get a blank screen with a big, red block slapped on.
Ta-da! That's how you make a rectangle. Hey, I might as well give you the steps to making a rectangle like what I did for doing a shape in general, in case you forget something or the order. Here is the list:
Location - Left-Right
This is the distance the rectangle will be from the left side of the screen.
Location - Top-Bottom
This is the distance the rectangle will be from the top of the screen.
Size - Width
How wide the rectangle will be.
Size - Height
How tall the rectangle will be.
That's the end of this little bit on rectangles. Until next time!