pygame is
Simple DirectMedia Layer is
Site Swing

verletCloth01 - 1.0

Eric Pavey (akeric)



Simple verlet based 'cloth' simulation.

  • Grab and move and pin particles to modify the sim.
  • See details on the code's home page.
  • Expects a 3-button mouse.
  • You can LMB-click on any particle to make the particle stick to the mouse.
  • LMB-click again, and the particle will stick in space.
  • If you RMB on a stuck particle, it will unstick.

If you grab just the source, you'll also need a fixed-up version of the Pygame vec2d lib, which you can download from my site here:

Based on the 2001 Siggraph paper:


Home Page:


click to view original size


verletCloth01 - 1.0 - Jul 4, 2010 account Comments

If you wish to leave a comment with your account, please sign in first.

July 12, 2010 1:41pm - Eric Pavey - nickname: (akeric)
reading my mind ;) My currently local tests have modified it to auto-generate a random spread of particles, and then connect them via constraints based on a distance check \ max # of constraints per particle. Not quite there yet but gives some creepy spider-web like results. If I can get that working I'll move into the 3d realm...
July 10, 2010 12:34pm - DR0ID - nickname: (dr0id)
Idea: how would an image look that is mapped on the grid? Would be a cool thing to play around.

Using opengl it should be fairly easy to map an image onto the grid.
July 7, 2010 3:26pm - DR0ID - nickname: (dr0id)
There is not approval process, I have renamed it myself by now.
July 7, 2010 11:49am - Eric Pavey - nickname: (akeric)
lol, I didn't realize I could fix it. Just updated both it and the vec3d lib. However, I don't see my changes reflected... maybe there's an approval process first? Thanks for the headsup on the "<", I don't know anything about html tags ;)
July 6, 2010 2:26pm - DR0ID - nickname: (dr0id)
You are right, I must have been confused. Maybe you should update the Vec2d class in the cookbook?

The "<" is a html tag (probably because its on a web page) and should be replaced with a "lower than".
July 6, 2010 11:51am - Eric Pavey - nickname: (akeric)
The class name in the source is Vec2d, the *module* name is ;)

Irony is in the source code on Pygame site, the class name *is* lowercase, so I actually made it conform to pep8 in my source.
The 'problem' is down around line 400, in the func testAngles() :

self.assert_((v - v2).length < .00001)

That line gets angry, looks like there is corruption in the source: "<". I just comment it out to get things working again. Although I suppose you could just replace the bad text with a comma ",".

Glad you like the program ;)
July 5, 2010 2:39pm - DR0ID - nickname: (dr0id)
What did you fix in Vec2d? You should know that a class name should start with a capital letter according to pep8.

Nice implementation. I have been playing around with it.

our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
Feb 21, 2017

Jan 31, 2017

Jan 24, 2017

Jan 18, 2017

Jan 7, 2017

Dec 30, 2016

Dec 8, 2016

Nov 28, 2016

Nov 27, 2016

... more!
for pygame related questions, comments, and suggestions, please see help (lists, irc)