figured out how to draw a rectangle

This commit is contained in:
milanjaeckel 2026-05-10 09:43:55 +02:00
parent 518e5502f4
commit 7bb88ebd07
2 changed files with 6 additions and 7 deletions

10
main.py
View File

@ -2,14 +2,12 @@ import pygame as pg
#start pygame #start pygame
pg.init() pg.init()
screen = pg.display.set_mode((800, 600)) screen = pg.display.set_mode((800, 800)) #window (size)
clock = pg.time.Clock() clock = pg.time.Clock()
running = True running = True
color = (0, 0, 0) #rectangle color
while running: while running: #open window
lead_x = 20
lead_y = 20
for event in pg.event.get(): for event in pg.event.get():
if event.type == pg.QUIT: if event.type == pg.QUIT:
@ -19,7 +17,7 @@ while running:
screen.fill("white") screen.fill("white")
#chess game #chess game
pg.draw.rect() pg.draw.rect(screen, color, pg.Rect(0, 0, 100, 100))
#flip display to put game on screen #flip display to put game on screen

View File

@ -1,4 +1,5 @@
"Chess game" "Chess game"
---SOURCES--- ---SOURCES---
https://www.pygame.org/docs/tut/ImportInit.html https://www.pygame.org/docs/tut/ImportInit.html
https://www.geeksforgeeks.org/python/how-to-draw-rectangle-in-pygame/