Pygame (Python Game Development) Tutorial - 6 - Draw Rect and Fill

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Just want to say that this is awesome, teaching me a lot. Very concise too! Recommended for sure

westaylorx
Автор

I love these videos. They're very helpful. This is exactly what I need to make project. Thank you very much

silentaqua
Автор

Good videos, I like the detailed explanations of basics, very helpful for total beginners, thank you

benjamind.halford
Автор

do you also know how to delete a drawn rectangle ?

nicovogel
Автор

hi there sir, i have a problem with running this program because it says this:
Traceback (most recent call last):
File projects/pygame 1.py", line 25, in <module>
pygame.draw.rect(gameDisplay, black, [lead_x, lead_y, 400, 300, 10, 10])
TypeError: Rect argument is invalid

I've followed every step in the video but it wont work can you help me plz?

elgreco
Автор

thank you for your
GREAT tutorials!😆😆😆

spirosbarbakos
Автор

Thank you for the video, it's very helpful). But I don't understand why fill is better than rect ??

Karina-fh
Автор

do i have to define the colours in variables every time i use one? if so that would be so so so frustrating

artistella
Автор

hello! please help me asap!
I have a rectangle drawn on a screen using python.draw.rect() . now when an angle is given by the user, i want the rectangle to rotate by that angle. i am unable to do so. answer would be greatly appreciated! thank you!

ankithguzz
Автор

hey, man. I'd like to create a checkerboard but the code isn't working properly. The code is the following:

import pygame

pygame.init()
gameDisplay = pygame.display.set_mode((800, 800))



def square(x, y, w, h, color):
pygame.draw.rect(gameDisplay, color, [x, y, w, h])


def createBoard():
xpos = 0
ypos = 0
color = 0
width = 100
height = 100
black = (180, 137, 60)
white = (255, 255, 255)
number = 0
print(color, number, (xpos, ypos))

for i in range(8):
for j in range(8):
if color % 2 == 0:
square(xpos, ypos, width, height, white)

else:
square(xpos, ypos, width, height, black)


xpos += 100
color += 1
number += 1
print(color, number, (xpos, ypos))

xpos = 0
ypos += 100


print(color, number, (xpos, ypos))

gameDisplay.fill((255, 255, 255))
createBoard()




quitGame = False

while not quitGame:
for event in pygame.event.get():
if event.type == pygame.QUIT:
quitGame = True
pygame.quit()
quit()

heitorantunesalcantra
Автор

How do you make an object disappear and appear in pygame

trashdude
Автор

I am not able to do it i think it is because I add a background image rather than a color.

femylijo
Автор

The box isn't showing for me.

import pygame

pygame.init()

gameDisplay = pygame.display.set_mode((1280, 720))


#pygame.display.update()

white = (255, 255, 255)
black = (0, 0, 0)
pygame.draw.rect(gameDisplay, black, [640, 360, 25, 25])
gameDisplay.fill(white)




gameExit = False

while not gameExit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
gameExit = True;

pygame.display.update()



pygame.quit()
quit()

thealien
Автор

 get an error that says gameDisplay not defined .... what does that mean?

netherlillyarts
Автор

Anyways, I am doing this on 3.2, your tutorial for installing Pygame had me scouring the web for hours looking through tutorials before finally installing python 3.2 and the compatible pygame msi file.

orekihoutarou
Автор

whenever i try to fill the screen white, its not happening, its always black, i actually named the set_mode as screen and was using screen.fill(white).can anyone help please

prakashgupta
Автор

From this tutorial on I suddenly get the error message: Segmentation fault: 11. Does someone know how to fix this?

heindewilde
Автор

why do we call pygame.quit() and quit()? why use both?

BeYakko
Автор

I'm getting a plane black screen :(

straighter
Автор

TypeError: must be pygame.Surface, not list

HugoIetsGaming