How to draw a rectangle in Pygame - Python Programming Tutorial

Publié le: 12 avril 2023
sur la chaîne: Something Simple
2,252
19

This video explains how to draw a rectangle in Pygame as well as addresses common issues that people may run into while learning this.

Code:
import pygame

initial pygame
pygame.init()

surface, color, and Rectangle object
surface = pygame.display.set_mode((1000, 1000))
color = (255, 0, 0)
rectangle = pygame.Rect(500, 500, 100, 200)

draw rect function
while True:
pygame.draw.rect(surface, color, rectangle)
pygame.display.flip()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit(0)

Hope this video helped someone and I wish you luck on your programming journey!


Sur cette page du site, vous pouvez voir la vidéo en ligne How to draw a rectangle in Pygame - Python Programming Tutorial durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Something Simple 12 avril 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 2,252 fois et il a aimé 19 téléspectateurs. Bon visionnage!