#PyMunk

Alexandre B A Villaresvillares@pynews.com.br
2025-04-29

A small Pymunk example for class.
No interactive segment-wall drawing for this one. And I can't use pickle for this sketch in imported mode :(
(see previous day for both features and the triangulated polys!) Code at: github.com/villares/sketch-a-d
More sketch-a-day: abav.lugaralgum.com/sketch-a-d
If you like this, support my work:
paypal.com/donate/?hosted_butt
liberapay.com/Villares
wise.com/pay/me/alexandrev562
#pymunk #Processing #Python #py5 #CreativeCoding

A collection of balls and boxes to test the Pymunk 2D physics library.
Alexandre B A Villares 🐍villares@ciberlandia.pt
2025-04-27

I want to simplify #pymunk + #py5 use for my students but I struggle with finding good strategies… Pymunk has two types of (linked) objects for each simulated object: body and shape. For complex objects (like concave shapes) you can use more than one convex shape linked to the same body. In these cases I usually want to have an extra shape to draw and hide the triangulation.
I don't want to keep extra data structures to track the simulation objects to draw. I tried both extending and monkey patching either body or shape objects to be "drawable" so I can just iterate the native pymunk structures and ask stuff to draw themselves (would be nice, huh?), but there is always some snag. If I extend shape classes, I stumble on the complex objects with many shapes drawn with divisions. If I extend the Body class, the problem is static objects have shapes but share a virtual constant body, more of a flag, so I can't add anything to it, so back to keeping track of a separate list of static shapes… Then performance & serialization issues, I want to be able to easily pickle simulations, but if I add Py5Shape objects to the extended/modified classes they become unpickable...
I have bigger fishes to fry right now (the paralyzing PhD) but this is something I would like to pair with someone more experienced to work on.

Alexandre B A Villares 🐍villares@ciberlandia.pt
2025-04-22

I'm obviously completely biased, but, if you are an educator teaching #Python and using #pygame / #pygamece, do check out #py5 (py5coding.org).

I'm sure other sprite & game stuff must be easier in pygame, but I'm adapting a #PyMunk example, and IMHO, events are so much easier in py5...

(I'll try post it here tomorrow, I should be doing something else, as usual...)

Jörg Kantelkantel
2025-02-21
Jörg Kantelkantel
2025-02-14
Alexandre B A Villares 🐍villares@ciberlandia.pt
2024-11-17

Updated: Sharing today a new version of my #Thonny portable (the beginner friendly #Python IDE) with #py5 #shapely #trimesh and #pymunk pre-installed. This "re-packaged distribution" makes it easier for my students to have a #CreativeCoding environment on Windows, and is specially useful for school labs with installation constraints...

Please help me test it!
github.com/villares/thonny-por
Some code: abav.lugaralgum.com/como-insta

I'd like help to build and sign a MacOS "equivalent" and maybe make a Linux AppImage, I'm not sure if AppImage will work as it would need to let people install further libraries. DM of you'd like to help!

Alexandre B A Villares 🐍villares@ciberlandia.pt
2024-10-04

@eltonfc rsrsrs, pois é, isso me lembra o caso do #pymunk que só sabe simular a física (2D) de corpos convexos e aí o jeito é triangular corpos com concavidades e fazer um corpo "composto" dos triângulos para poder simular.

Alexandre B A Villares 🐍villares@ciberlandia.pt
2024-07-13

Galera, como muitos lugares em que eu dou aula usam Windows, eu andei montando um pacotinho "portátil" usando o #ThonnyIDE portable, que já vem com #Python 3.10, e acrescentei a biblioteca de desenho que eu uso, #py5 e mais umas coisinhas como #shapely, #trimesh e #pymunk... se alguem quiser testar, atualizei hoje algumas coisas:

github.com/villares/thonny-por

Thonny e py5 rodam no MacOS e no GNU/Linux também. Pra quem quiser saber mais sobre o py5 (e essa dobradinha com o Thonny IDE) veja esta páginai: abav.lugaralgum.com/como-insta (nessa página está um link para uma versão anterior do portable para Windows que pretendo trocar por essa que está em testes). #ProgramaçãoCriativa #Python #Processing

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst