Book
Module 5 - Section 0 - Repeat!
Module 5 - Section 0 - Repeat!
Completion requirements
View
This section is a repetition of the previous modules
5.0.4 - Drawing shapes and text
All the following commands are written inside the main loop inside section "# --- Drawing code should go here"
Draw a rectangle
pygame.draw.rect(screen, WHITE, [50, 50, 50, 50])
Draw a hollow circle
pygame.draw.circle(screen, RED, [200, 140], 30, 5)
Draw an ellipse
pygame.draw.ellipse(screen, RED, [20, 20, 250, 100], 2)
Draw a polygon
pygame.draw.polygon(screen, GREEN, [[50,100],[0,200],[200,200],[100,50]], 5)
Draw text
font = pygame.font.SysFont('Calibri', 25, True, False)
text = font.render("My text",True,BLACK)
screen.blit(text, [250, 250])