Simulating physics in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ธ.ค. 2024

ความคิดเห็น • 121

  • @namdao2672
    @namdao2672 2 ปีที่แล้ว +32

    Clear Code is a underrated channel that only lucky people can find, and he's really know how to teach and make people understanding problem step bt step.

  • @darkknightanimation3493
    @darkknightanimation3493 4 ปีที่แล้ว +75

    OMG, smooth, you actually explain, underatted!!! You deserve more, i did not even know pymunk existed!

  • @Purp0w
    @Purp0w 2 ปีที่แล้ว +4

    Thanks for the good tutorials!

  • @mathsplug6800
    @mathsplug6800 4 ปีที่แล้ว +41

    This is fantastic.
    Physics simulation made easy on python.
    I spent ages doing this on Matlab and one afternoon on this.
    Thanks for the lesson

  • @GuilhermeDiGiorgi
    @GuilhermeDiGiorgi 4 ปีที่แล้ว +74

    Pymunk? Holy... I always create the whole energy, speed, momentum, gravity logic into pygame to make my balls run. Im glad theres a library for it. I havent done it before, but doing balls colliding with rects and calculating the rotational and regular speeds and reactions would be hell.

    • @ClearCode
      @ClearCode  4 ปีที่แล้ว +12

      Check out the pymunk website, it has lots of examples of cool projects

    • @idontwanthackersanymore5224
      @idontwanthackersanymore5224 2 ปีที่แล้ว

      How could you do that on your own

    • @0rd3r
      @0rd3r 2 ปีที่แล้ว

      u made me feel dumb

  • @apurvakumardani172
    @apurvakumardani172 3 ปีที่แล้ว +22

    Full physics...... Physics+Python=Phython

  • @kefrov
    @kefrov 3 ปีที่แล้ว +7

    This is amazing, never knew this library existed. I'm never making my own physics again, thanks.

  • @malterothkamm3579
    @malterothkamm3579 4 ปีที่แล้ว +7

    Just found your channel, brilliant tutorials.
    I hope (and think) u channel grows fast :)
    Much love from Germany!!!

    • @ClearCode
      @ClearCode  4 ปีที่แล้ว +1

      Vielen dank :)

    • @malterothkamm3579
      @malterothkamm3579 4 ปีที่แล้ว +1

      @@ClearCode wait are you actually from Germany? :D

    • @ClearCode
      @ClearCode  4 ปีที่แล้ว +3

      I grew up in Germany, but things got weird and I ended up living in lots of different countries. It's a bit weird... I do miss some good Döner though :D

    • @Tila1
      @Tila1 4 ปีที่แล้ว

      @@ClearCode facts, can you make a video about your atom settings, I love that font

    • @ClearCode
      @ClearCode  4 ปีที่แล้ว +2

      @@Tila1 hey, I am actually using the sublime code editor, here are the settings: {
      "caret_extra_bottom": 1,
      "caret_extra_top": 1,
      "caret_extra_width": 0.5,
      "caret_style": "solid",
      "color_scheme": "Packages/Base16 Color Schemes/Themes/base16-one-light.tmTheme",
      "font_size": 28,
      "gutter": true,
      "highlight_line": true,
      "ignored_packages":
      [
      "Vintage"
      ],
      "line_numbers": false,
      "line_padding_bottom": 4,
      "line_padding_top": 4,
      "mini_diff": false,
      "overlay_scroll_bars": "enabled",
      "theme": "ayu-light.sublime-theme"
      }

  • @scubing9486
    @scubing9486 4 ปีที่แล้ว +2

    Man you did an excellent work your channel is no one in TH-cam 👌👌👌🤘

  • @roocode618
    @roocode618 3 ปีที่แล้ว

    You are the best tutor I have ever seen

  • @umanglunia2194
    @umanglunia2194 4 ปีที่แล้ว +8

    This is the only pygame tutorial that makes use of pymunk...
    I didn't even know it existed.
    Awesome tutorial, you deserve more subscribers.

  • @muradpetrosyan5128
    @muradpetrosyan5128 4 ปีที่แล้ว +4

    Bro how can you only 430 subs, You deserve moreee!!!

    • @shauryapatel8372
      @shauryapatel8372 4 ปีที่แล้ว +1

      dont worry he got 2k now!

    • @amatris
      @amatris 3 ปีที่แล้ว +1

      Now about 10k

  • @midnightdev73
    @midnightdev73 4 ปีที่แล้ว +3

    I'm just starting out as a programmer and you should have a lot more subs then you have now :)

  • @suyashmisra7406
    @suyashmisra7406 3 ปีที่แล้ว +1

    pos_x = int(ball.body.position.x)
    ValueError: cannot convert float NaN to integer
    >>>
    if you faced this error , a quick fix is to pass two integers as arguments to
    body = pymunk.Body(1,1,pymunk.Body.STATIC)
    in the function definition for static_ball().
    great tutorial, thanks a lot!

  • @jasonwalon5470
    @jasonwalon5470 4 ปีที่แล้ว +1

    you are amazing!!! keep doing good stuff

  • @atharvapatil7474
    @atharvapatil7474 4 ปีที่แล้ว +4

    I want more videos on Pymunk !!!

  • @vilasd.chawan1769
    @vilasd.chawan1769 ปีที่แล้ว

    This video is really helpful thanks for sharing your knowledge with us 🙂

  • @ChannelMovies
    @ChannelMovies 3 ปีที่แล้ว +1

    This video very helpfull, I really like this video

  • @farrasfauzan5613
    @farrasfauzan5613 4 ปีที่แล้ว +1

    Great video!

  • @ecniiv
    @ecniiv ปีที่แล้ว

    13:03 I somehow didn't get an error but I just copy paste what you do, I assume it's because of an update since this video is from 2 years ago

  • @basiccoder2166
    @basiccoder2166 4 ปีที่แล้ว +1

    That was a very cool tutorial
    Thanks Clear Code btw you can get a satisfactory result if you use below co-ordinates
    balls.append(static_ball(space,(200,100)))
    balls.append(static_ball(space,(310,175)))
    balls.append(static_ball(space,(200,250)))
    balls.append(static_ball(space,(310,325)))

  • @kacperzawisza7040
    @kacperzawisza7040 4 ปีที่แล้ว +2

    good video men!!!

  • @CPlusPy
    @CPlusPy 11 หลายเดือนก่อน +2

    Great video! Though my code won't run with me constantly moving my mouse, otherwise it will pause until I move it again, what's going on here?

    • @ClearCode
      @ClearCode  11 หลายเดือนก่อน +2

      you messed up the indentation for the game loop!

    • @CPlusPy
      @CPlusPy 11 หลายเดือนก่อน

      @@ClearCode Thanks so much, im sorry i hadnt seen this earlier thanks for the help with this and the entire project, it was a fun one and Im hoping to code it more

  • @marcoshaw1
    @marcoshaw1 2 ปีที่แล้ว

    At 20:25 I don't know if it's newer versions of the modules, but I had to use a == or it was failing.

    • @StarFury2
      @StarFury2 2 ปีที่แล้ว +1

      He made a mistake, it must be ==

  • @davinaazizah609
    @davinaazizah609 ปีที่แล้ว

    Thank you it works sir! I'll use it for my presentation

  • @sjacobson42
    @sjacobson42 3 ปีที่แล้ว

    My kingdom for a portable version of Python with GUI editor and Pygame all connected. I’d use it with all 100+ of my game design students

  • @jayengel9012
    @jayengel9012 3 ปีที่แล้ว +2

    pls do a kinematic body tutorial!

  • @piratesofphysics4100
    @piratesofphysics4100 2 ปีที่แล้ว

    great video

  • @mengguojing6556
    @mengguojing6556 2 ปีที่แล้ว +1

    This is super helpful!! I just wonder if we can get the pixel array of the simulated animation?

  • @apurvakumardani172
    @apurvakumardani172 3 ปีที่แล้ว +2

    But now, the apple.body.position attribute returns integer.... Maybe due to updates

  • @senthilkumar-co4vr
    @senthilkumar-co4vr 2 ปีที่แล้ว +1

    gravity and step function is not working
    is that because of any new update

  • @avstechindian8807
    @avstechindian8807 3 ปีที่แล้ว +1

    I am your 1100th liker

  • @thatgamer_2397
    @thatgamer_2397 3 ปีที่แล้ว +1

    what should I do if the image of the apple is too big? what is the code to change its size? and where is the proper placement in the script?

  • @miguelcolladogomez
    @miguelcolladogomez 2 ปีที่แล้ว +1

    Kick to PEP8, as always.

  • @shikshya2594
    @shikshya2594 3 ปีที่แล้ว

    Holy Fuck I'm never writing collision functions in pygame ever again
    Thank you so muchhhhhhhhhhhh

  • @ademromdhane1271
    @ademromdhane1271 2 ปีที่แล้ว

    thank's that video was very helpful

  • @StarkRaveness
    @StarkRaveness 4 ปีที่แล้ว +4

    So good thanks! However after collisions I would expect some rotations on the apples, is this to do with friction?

    • @iwishformanythings
      @iwishformanythings 10 หลายเดือนก่อน

      i think you could add it yourself, idk how but check out pymunk's documentaries or keep searching, you might find one

    • @superkult
      @superkult 7 หลายเดือนก่อน

      I have the same problem and i cant figure it out.. Im too stupid for the pymnunk dopcumerntaions

  • @mitchellfolbe8729
    @mitchellfolbe8729 4 ปีที่แล้ว +2

    really enjoyed that. looking forward to more projects. the apple i found has a boarder around it so it looks awkward. do you have a git link for yours?

    • @sillicon8227
      @sillicon8227 3 ปีที่แล้ว

      That's a problem with your png

  • @austineadah2843
    @austineadah2843 3 ปีที่แล้ว +1

    Nice.. could one simulating a 3D floating object in water with python?

  • @Xinurval
    @Xinurval 3 ปีที่แล้ว +1

    Hi! do you have a download link for the images or code by any chance... im getting some problems and idk how to fix, perhaps it could be because ive loaded the wrong images or incorrect code

  • @aminzar446
    @aminzar446 4 ปีที่แล้ว +1

    Hy it's possible to do a Simulation of a Alternative Photographic Processes? Thanks

  • @arandomboredindividual7855
    @arandomboredindividual7855 4 ปีที่แล้ว +2

    Hey man, what is the IDE/Editor you're using in the video? Im really interested...

  • @dnyaneshwarikadam7207
    @dnyaneshwarikadam7207 2 ปีที่แล้ว +1

    I get this error:
    AttributeError: module 'pymunk.body' has no attribute 'STATIC'
    What should i do?

    • @StarFury2
      @StarFury2 2 ปีที่แล้ว +1

      Check for capital "B" in body. You actually want to instance of a Body() class, like:
      body = pymunk.Body(body_type=pymunk.Body.STATIC)

  • @Ishaan_Garud
    @Ishaan_Garud 2 ปีที่แล้ว

    Hey , Is there any way to create a non-blocky, curvy terrain in pygame??????

  • @mehmetberkayozbay2531
    @mehmetberkayozbay2531 4 ปีที่แล้ว +1

    how can i create rectangle body for sprite

  • @ohtych1004
    @ohtych1004 4 ปีที่แล้ว +2

    Would it be possible to use pymunk with ursina?

    • @ClearCode
      @ClearCode  4 ปีที่แล้ว +3

      Pymunk does nothing but physics calculations and returns numbers, although only for 2d spaces. So yeah, you could connect it, all you need are the ursina screen dimensions.

    • @ohtych1004
      @ohtych1004 4 ปีที่แล้ว

      @@ClearCode thank you

  • @brianm2572
    @brianm2572 4 ปีที่แล้ว

    Great vid

  • @scottli9012
    @scottli9012 3 ปีที่แล้ว +1

    Can we get the source somewhere?

  • @cmop0693
    @cmop0693 3 ปีที่แล้ว

    i dont know why I cant see any response on the screen
    It has correct background color, but neither ball nor apple are visible.

    • @cmop0693
      @cmop0693 3 ปีที่แล้ว

      code is exactly same and I am using pycharm professional, not sure why it is not working.

    • @cmop0693
      @cmop0693 3 ปีที่แล้ว

      So i have made some changes and now it is working. Awesome explanation.

    • @cmop0693
      @cmop0693 3 ปีที่แล้ว

      @Arpan Rai i got it, just switch the position of screen fill to the top of the while loop.

  • @passion002
    @passion002 3 ปีที่แล้ว +1

    Do the same thing by using Ursina please

  • @anis6674
    @anis6674 2 ปีที่แล้ว

    bruh i used to litteraly create physics manualy by giving the balls an x velociy and a y velocty and adding the force of grvity to theem and add the velocity to the balls position thoose days are over now

  • @josephwilliamcosta
    @josephwilliamcosta 2 ปีที่แล้ว

    do you have a copy of this code posted anywhere? Thank you!

  • @biophotography903
    @biophotography903 2 ปีที่แล้ว

    How can I make the image smaller?

  • @techos3253
    @techos3253 3 ปีที่แล้ว

    What text editor do you use?

  • @qidirbinu5640
    @qidirbinu5640 3 ปีที่แล้ว

    I have a problem:
    if event.type = pygame.MOUSEBUTTONDOWN:
    ^
    SyntaxError: invalid syntax
    when I change to:
    if event.type == pygame.MOUSEBUTTONDOWN:
    the syntax does not error anymore but:
    TypeError: create_apple() missing 1 required positional argument: 'pos'
    can someone help me? 😅

  • @raviyadaw7715
    @raviyadaw7715 4 ปีที่แล้ว

    Awesome

  • @slowmomoose
    @slowmomoose 3 ปีที่แล้ว

    Can I add movement to this? Or can I just watch

  • @Pixel_Magic
    @Pixel_Magic 3 ปีที่แล้ว

    Dont work... Color of background isn't changing. And i dont see ball, i tryed to make it white. But its not work...

  • @v-dev4800
    @v-dev4800 4 ปีที่แล้ว

    hey,is pymunk uses lot of cpu and is pygame fps decrese

  • @josephinealmas3692
    @josephinealmas3692 4 ปีที่แล้ว +1

    My screen in PyGame is black. No errors showing up. Someone please help me!

    • @thebosssss9634
      @thebosssss9634 2 ปีที่แล้ว

      not sure if it matters to you anymore, but move the code at the end under the while loop

  • @praizdev
    @praizdev 2 ปีที่แล้ว

    Can games created using pygame be deployed?

  • @capybara8581
    @capybara8581 3 ปีที่แล้ว

    sir ! how can i run the code that i created in pymunk in my website?\

  • @somebody6837
    @somebody6837 3 ปีที่แล้ว

    Hello! I just have a simple question that I want the answer of. How do you add anti-aliasing to the circles?

    • @ClearCode
      @ClearCode  3 ปีที่แล้ว

      check out the gfxdraw library of python, it can do that. www.pygame.org/docs/ref/gfxdraw.html

    • @somebody6837
      @somebody6837 3 ปีที่แล้ว

      @@ClearCode will you ever make another video like this but this time with classes?

  • @videogamegenerator5106
    @videogamegenerator5106 3 ปีที่แล้ว

    Please upload about poly too. instead of circles.

  • @lyrics4047
    @lyrics4047 3 ปีที่แล้ว

    What text editor you use ? :D

    • @sillicon8227
      @sillicon8227 3 ปีที่แล้ว

      The original python ide

  • @YOy50
    @YOy50 4 ปีที่แล้ว

    When I put the apple it won't show

  • @zihasoo
    @zihasoo 3 ปีที่แล้ว

    thank you

  • @blaukampfflieger
    @blaukampfflieger 3 ปีที่แล้ว

    Um clear code? i got a problem
    The object of type "int" has no len().
    SOMEONE HELP PLS

    • @ClearCode
      @ClearCode  3 ปีที่แล้ว

      you created an integer when you were supposed to make a list

    • @blaukampfflieger
      @blaukampfflieger 3 ปีที่แล้ว

      i did what you said what's wrong

    • @jachymdolezal5103
      @jachymdolezal5103 3 ปีที่แล้ว

      @@blaukampfflieger check your code u might make a type somewhere it happened to me many times.

  • @0rd3r
    @0rd3r 2 ปีที่แล้ว

    why...
    why u dont follow the rules of pep 8
    rly good tutorial btw

  • @anilkumarsharma8901
    @anilkumarsharma8901 3 ปีที่แล้ว +1

    please give code file link

  • @tushar_mahajan
    @tushar_mahajan 2 ปีที่แล้ว

    Kyu Abhishek ne maya ko apne bhai ke paas bheja?

    • @ajay5077
      @ajay5077 ปีที่แล้ว

      Kyu?

    • @tushar_mahajan
      @tushar_mahajan ปีที่แล้ว

      what is this, I have not commented this

    • @ajay5077
      @ajay5077 ปีที่แล้ว

      Lol, it's you.

  • @sucram314
    @sucram314 3 ปีที่แล้ว

    It is very laggy for me

  • @rahotep4927
    @rahotep4927 4 ปีที่แล้ว

    You should have a source code

  • @ponto30_42
    @ponto30_42 5 หลายเดือนก่อน

    static balls

  • @xseis.
    @xseis. ปีที่แล้ว

    pymunk. 1sst off im not gay, 2nd off im a monké but not monk alr

  • @ChiragSangma
    @ChiragSangma 3 ปีที่แล้ว +1

    Give the code!!!!!!!!!!!!!!!!!

  • @gamertronky8648
    @gamertronky8648 2 ปีที่แล้ว

    you have so big screen

  • @oyunlarveparodiler3221
    @oyunlarveparodiler3221 4 ปีที่แล้ว +2

    Phython users:A really basic physic simulator in 23 minutes and with a lot of code
    Unity users:Rigidbody 2D/3D Collider 2D/3D a complicated physics simulator in 2 seconds and with zero code *GO BRRR*