Collisions in Pygame - Beginner Tutorial

preview_player
Показать описание
In this video I will explain how to check for collisions in Pygame.

I'll go over three different collision types which are rectangle collisions using colliderect(), point collisions using collidepoint() and line intersection collisions using clipline()

I'll also explain how I use these collisions in my projects for player collision, button clicking and even AI.

Рекомендации по теме
Комментарии
Автор

My Dude. I have been playing with pygame for months now. Got number of projects under my belt. I always find myself coming back to your vids for some assistance...This here, is a perfect example. Been looking for a means of determining line collisions...and lo and behold ... Russ has done it again!!

Much appreciated man!!

HoRRoRlets
Автор

Hi! Thanks for this amazing tutorial series, they are just awesome, the way you explain is really really nice. So please keep it on and continue this series on pygame. I must say that your channel is underrated but whoever will visit your channel will definitely love and follow it. Thanks once again.

DineshVaidyaOfficial
Автор

Small amount of likes for a really good and useful video, thanks

Quilonis
Автор

I follow your lessons it're very interesting and easy to understand Thanks for your great job

alboukhari
Автор

Intro 0:00
Rectangle Collisions 0:39
Point Collisions 6:12
Line Collisions 8:26

windchaser
Автор

Getting interesting more and more each lesson.

SkyFly
Автор

thank you so much, very helpful content

Meysamm-xinv
Автор

guy thanks because I made it if the box1 touch's box2 it make just basically a makeshift edge grip

boxhead-zksn
Автор

Hi, I need help with something.
I have made a Space Invaders game with rect collision. The enemies and the player are not rect objects. I noticed a problem with the game: The collision ONLY works if I hit the enemies on the right corners. I am using distance as my collision but colliderrect-based collision does not work either. Is it supposed to be like that with non-rectangle objects or have I done something wrong? Thank you for your answer!

BlinkersGameDev
Автор

How can I tweak the position of the hitbox rectangle relative to whatever model/ sprite I'm using? Can I do that within the library or?

dibosh
Автор

I get collisions but I don't understand how to exactly handle them once they happen.

I have a little space invaders game but instead of ships you shoot space rocks or they hit you and you die, but my ship can shoot, once a collision is detected I need to know how I can make that rock dissapear, I am currently just moving the rock back to the top so it looks like you just blow it up but I will need to actually just remove the rock from the game, how can I do this?

yourboizach
Автор

Why define all the colors as RGBs instead of just use the abailable color presets as string? For example

WHITE = (225, 225, 225)
pygame.draw.rect(screen, WHITE, obstacle)
#instead of
pygame.draw.rect(screen, "white", obstacle)

alvarohernandez
Автор

for some reason the "rect_1 = pygame.Rect(0, 0, 25, 25)" is giving me "'module' object is not callable" error

albin