Python Physics Simulation. Galton Board. Pymunk Tutorial
ฝัง
- เผยแพร่เมื่อ 26 ก.ค. 2024
- Python Tutorial on Physics Simulations using the Pymunk engine and the Pygame library. In this video we will recreate the Galton board experiment.
More Python Projects: • Python Projects
SourceCode:
github.com/StanislavPetrovV/P...
#coderspace #python #pymunk #pygame #galtonboard
#programming #coding #programmer #developer #technology #code
Your tutorials are fantastic. I have learned so much from them. Thanks for doing them.
thank you so much for sharing your experience and code in your videos. It helped me a lot in understanding several programming concepts and solutions.
Very (VERY!) good tutorial. Thank you!!!
I couldn't learn pymunk due to lack of resources but I started learning with your video thank you
WHO R U GETTING JUST 225 views
man you make the perfect videos
keep it up
Interesting tutorial. Thanks :)
Great!
I follow the code exactly, but after adding elasticity, the ball does not bounce up at all. It just falls downward and stucks to floor. (The added friction changed the horizontal lines like in your demo.) Thanks for the great video. I've learned a lot.
Here before your channel grows big!
thanks. I really appreciate it
BIG LOVE
my bad, small typo. Your code works perfectly
Is it OK for me to copy your code so I can play around with this stuff and learn it?
Yes, you can do whatever you want with this code. But comply with the MIT license
How long have you been coding for ?
about three years
Why won't it work:
import pygame as pg
import pymunk.pygame_util
pymunk.pygame_util.positive_y_is_up = False
RES = WIDTH, HEIGHT = 1200, 1000
FPS = 60
pg.init()
surface = pg.display.set_mode(RES)
clock = pg.time.clock()
draw_options = pygame.pymunk_util.DrawOptions(surface)
space = pymunk.Space()
space.gravity = 0, 2000
ball_mass, ball_radius = 1, 60
ball_moment = pymunk.moment_for_circle(ball_mass, 0, ball_radius)
ball_body = pymunk.Body(ball_mass, ball moment)
ball_body.position = WIDTH // 2, 0
ball_shape = pymunk.Circle(ball_body, ball_radius)
space.add(ball_body, ball_shape)
while True:
surface.fill(pg.color('black'))
for i in pg.event.get():
if i.type == pg.quit:
exit()
space.step(1 / FPS)
space.debug_draw(draw_options)
pg.display.flip()
clock.tick(FPS)
This Code Was Unfinished Because I'm Just Testing
the Warning:
File "/data/user/0/ru.iiec.pydroid3/files/temp_iiec_codefile.py", line 18
ball_body = pymunk.Body(ball_mass, ball moment)
^
SyntaxError: invalid syntax