Collisions between moving objects

Поделиться
HTML-код
  • Опубликовано: 17 май 2024
  • A video about how to do collisions between objects, both static and moving ones. I will use pygame to implement it but the logic should work everywhere .
    If you want to support me: / clearcode
    (You also get lots of perks)
    Social stuff:
    Twitter - / clear_coder
    Discord - / discord
    Related videos:
    Introduction to Pygame: • The ultimate introduct...
    Deltatime: • Understanding framerat...
    Timestamps:
    00:00 - Intro
    13:00 - Collision logic
    19:32 - Collision implementation
    Project file:
    github.com/clear-code-project...
    Pastebin:
    pastebin.com/sN3vp3t9

Комментарии • 30

  • @JohnnyGrateful
    @JohnnyGrateful Год назад

    Such a great video. Thanks for being the guy who teaches me collisions! Appreciate it all!

  • @APOSTOLARA2000
    @APOSTOLARA2000 2 года назад +7

    Very nice tutorial on basic collisions, but as you said in the end those 2 "bugs" are a pain to fix and I haven't found the optimal way to address it. I am looking foward to a more advanced collision handling video!

  • @TasteDaRDX
    @TasteDaRDX 2 года назад

    Hi Chris, nice job explaining collisions. Would using Munk be more effective?

  • @TheBarryLight
    @TheBarryLight 2 года назад

    You save my life with this tutorial :D

  • @mewbot346
    @mewbot346 2 года назад +2

    Amazing!

  • @samperry8386
    @samperry8386 8 месяцев назад

    Thank you. My movement method is only linear up, down, left, right. I deployed your collisions function and my sprite is no longer a ghost!

  • @dmin72
    @dmin72 4 месяца назад

    Thank you so much for this tutorial of such a topic so hard to find. I have been studying this topic for a long time and I had come to, more or less, your same conclusions, although less simply than your brilliant solution. However, I needed to be assured on how to order the object update and draw operations and you helped me a lot about that. Unfortunately I don't use Pyton as a programming language and I miss the implementations of the PyGame library, in particular those on sprites and collision detection between them. It would be particularly interesting to understand how to resolve bitmap collisions between transparent sprites and not just filled rectangular ones, for example. I hope one day you will want to make a tutorial about this too.

  • @furykool
    @furykool 7 месяцев назад

    I implemented this in my project and it works well but it isn’t as springy as with static and moving object collision. The player gets slowed when moving in certain areas. Is that just lag or is it fixable?

  • @WingMaster562
    @WingMaster562 Год назад +4

    0:32 That moment that the red block just phases through the green block as it's being pushed by the blue block. I too have this issue with multi collision

    • @subarunatsuki1902
      @subarunatsuki1902 Год назад

      Do you found a solution?

    • @WingMaster562
      @WingMaster562 Год назад

      @@subarunatsuki1902 I'm still working on my collisions and pathfinding. Kinda went into many phases.
      But for that specific part, I realized that it was described in 16:58 and 51:54 The issue is when an object is being sandwich by two objects, the latest one overrides the other.
      What I did from this point on was "true collision" instead: From the original position, move an entity. If there is collison with anything: Move Back to the original position then reset Velocity to 0

  • @raphaelramesar2109
    @raphaelramesar2109 2 года назад +2

    Hey, absolutely love your work. Do you know of or have any videos which use the built in vector class in Pygame? I think it’s really powerful but can’t find any videos on it. Thanks.

  • @juniorMr
    @juniorMr 2 года назад +4

    Man ,your chanel is amazing .
    I watch you from Africa

    • @kingleo429
      @kingleo429 2 года назад +1

      Me too. Nigeria to be precise 😉

    • @YNightmareT
      @YNightmareT 3 месяца назад +1

      How? you have no internet 😂😂😂😂

  • @anantchandak9574
    @anantchandak9574 2 года назад +8

    That's why this is a good channel
    Thanks
    Just tell me can i make fruit ninja with pygame

  • @pbt189
    @pbt189 2 года назад +1

    As always, very nice and clear tutorial
    I just need help on the line: super(). __init__(groups) What exactly is the groups argument, and what does it do? I tried to find an explanation in the pygame documentation, but I'm still confused. I understand the __init__ method of the sprite class, but I'm not sure what the *groups argument means ?

    • @ClearCode
      @ClearCode  2 года назад +4

      all it does is put that sprite into the group when it is being initiated. It is essentially the same as group.add(sprite)

    • @pbt189
      @pbt189 2 года назад

      @@ClearCode Oh, great, didn't knew that.
      Thanks alot.

  • @Salomon_li
    @Salomon_li 2 года назад +1

    Please make a video tutorial on how to create an isometric game, thanks!

  • @kailasmanoj2121
    @kailasmanoj2121 2 года назад

    Hey can you plz do a video series on KivyMD
    Thanks

  • @SkyFly19853
    @SkyFly19853 2 года назад

    Real nice...
    ✅✅✅✅✅

  • @SkyFly19853
    @SkyFly19853 2 года назад

    Btw, have you ever made a chess game in Python?

  • @trolleandopervertidos7743
    @trolleandopervertidos7743 2 года назад

    What's that IDE? I'm using Pycharm but the colors doesn't match

    • @batatafritanhamnham
      @batatafritanhamnham 2 года назад

      I believe it's Sublime Text Editor, I recall him saying something about Sublime in another video. It's a great IDE, give it a try.

  • @Pieter_241
    @Pieter_241 2 года назад

    666 subscribers

  • @binkrassdufass
    @binkrassdufass 2 года назад

    Algo

  • @George_2983
    @George_2983 2 года назад

    I am the 525th person to see this video!

  • @amburger1984
    @amburger1984 2 года назад +3

    Im first again?

  • @ocoolwow
    @ocoolwow 2 года назад

    This is bug filled are you going to go more in depth?