Python Pygame Tutorial - Rectangle Based Collision Detection

  Рет қаралды 10,145

code.Pylet

code.Pylet

Күн бұрын

Пікірлер: 27
@BigAggLP
@BigAggLP 2 жыл бұрын
nice and straight forward tutorials, great videos!
@konradpodgorski1967
@konradpodgorski1967 5 жыл бұрын
That type of tutorials should be displayed at the top of search results :) Very useful tip, good job , keep it up !
@FiveMinuteGaming
@FiveMinuteGaming 7 жыл бұрын
Thank you, that's exactly what I needed :)
@codePylet
@codePylet 7 жыл бұрын
No problem. If you get stuck on anything let me know.
@trootrooper
@trootrooper 7 жыл бұрын
You have made pygame so easy to use. Thank you!
@codePylet
@codePylet 7 жыл бұрын
I'm really glad you like the videos. I'm working on a new collision detection video but I'm struggling to find time to get it made at the minute. It will arrive though :)
@metgaming9545
@metgaming9545 3 жыл бұрын
You could technically compile this into a function (though you would need to give alot of infomation) heres the code i used: def checkCollision(targetX, targetY, targetWidth, targetHeight, sourceX, sourceY, sourceWidth, sourceHeight): targetX2 = targetX + targetWidth targetY2 = targetY + targetHeight sourceX2 = sourceX + sourceWidth sourceY2 = sourceY + sourceHeight if targetX > sourceX2 or targetX2 < sourceX or targetY > sourceY2 or targetY2 < sourceY: return False else: return True # when calling the function, call it like this: checkCollision(targetX, targetY, targetWidth, targetHeight, objectX, objectY, objectWidth, objectHeight) # make sure to call the command in the game loop or it wont work.
@szymanek2k208
@szymanek2k208 7 жыл бұрын
What can I say except, like and thanks for tutorial. I will use this tip to my project. ;)
@codePylet
@codePylet 7 жыл бұрын
+Gimby Bronzu PL glad you found it useful :)
@billyalani2001
@billyalani2001 4 жыл бұрын
with the same logic, how could i be true only when it is above the object? spectacular video continues like this, thanks in advance :)
@szymanek2k208
@szymanek2k208 7 жыл бұрын
Can you in the next time will make a video about A* alghoritm etc. this good tips to make a game with AI. ;)
@codePylet
@codePylet 7 жыл бұрын
Interesting I'll have a look into that :)
@codePylet
@codePylet 7 жыл бұрын
Gimby!!!? Can you have a look at this A* implementation and let me know what you think please? drive.google.com/open?id=0BwDJQBs1OukNSXo2S2pFbjlkVzA
@szymanek2k208
@szymanek2k208 7 жыл бұрын
No bad but this code is very complicated for beginner users. I will make my version of A* alghoritm and will show you after some days ok?
@szymanek2k208
@szymanek2k208 7 жыл бұрын
No bad but it's very complicated for beginner users I think. My tip for you is make a Representative class exemplae - Squer_grid - next make a basic very basic pathfainding algh. based on it. What do you think ?
@szymanek2k208
@szymanek2k208 7 жыл бұрын
EXAMPLE: class Squer_grid(object): """ Klasa obslogujaca siatke/kwadraty. """ def __init__(self, width, height): self.width = width self.height = height self.walls = [] self.connetions = [vec(1, 0), vec(-1, 0), vec(0, 1), vec(0, -1), vec(1, 1), vec(-1, 1), vec(1, -1), vec(-1, -1)] def in_bounds(self, node): """ Falsz gdy mamy x lub y na minusie. """ return 0
@-AWEJOKER
@-AWEJOKER 5 жыл бұрын
this is so over-engineered and complex, just use pygame.Rect.colliderect(Rect)
@heavymetal1ization
@heavymetal1ization 4 жыл бұрын
I have no idea why on earth he has so many functions in literally every single class he makes, it's so confusing and unnecessary
@atlantic_love
@atlantic_love 4 жыл бұрын
@@heavymetal1ization Designing classes is not easy. Do you have a solution, for doing this with classes?
@atlantic_love
@atlantic_love 4 жыл бұрын
The problem is that you would have nested lists or arrays to keep track of attributes for all those rectangles. At the time of writing this comment, I don't know if he ended up putting all of these objects in a list or not.
@Divijcool
@Divijcool 2 жыл бұрын
your word code.Pylet yay 10points
@mason6300
@mason6300 5 жыл бұрын
Its lagging pretty bad on my macbook, even with just 10 stars
@atlantic_love
@atlantic_love 4 жыл бұрын
Sounds like you need Microsoft :D
Python Pygame Tutorial - Sprite Sheets
14:01
code.Pylet
Рет қаралды 32 М.
Learning Pygame by making Pong
28:39
Clear Code
Рет қаралды 206 М.
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 14 МЛН
Or is Harriet Quinn good? #cosplay#joker #Harriet Quinn
00:20
佐助与鸣人
Рет қаралды 57 МЛН
Angry Sigma Dog 🤣🤣 Aayush #momson #memes #funny #comedy
00:16
ASquare Crew
Рет қаралды 50 МЛН
Фейковый воришка 😂
00:51
КАРЕНА МАКАРЕНА
Рет қаралды 7 МЛН
Pygame Tutorial #7 - Collision and Hit Boxes
16:11
Tech With Tim
Рет қаралды 153 М.
Maze Solving - Computerphile
17:15
Computerphile
Рет қаралды 1,1 МЛН
Solving Wordle using information theory
30:38
3Blue1Brown
Рет қаралды 10 МЛН
Bounding Box Collision Detection - Game Coding Tutorial
9:15
Bytes N Bits
Рет қаралды 10 М.
Python Pygame Tutorial - Stage Manager: Objects & Viewport
23:25
code.Pylet
Рет қаралды 4,3 М.
Python Pygame Tutorial - Physics Style Gravity Jumping
19:46
code.Pylet
Рет қаралды 10 М.
Python Pygame Tutorial - Pixel Perfect Collision Using Mask
9:45
Python Pygame Tutorial - More Platforms
13:48
code.Pylet
Рет қаралды 3,5 М.
Coding Adventure: Simulating Fluids
47:52
Sebastian Lague
Рет қаралды 1,8 МЛН
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 14 МЛН