pygame is
Simple DirectMedia Layer is
Site Swing
Bouncy Ball tank

Bouncy Ball tank - 1.00

Ron Dippold (sizer99)



A simple bouncing balls demo to demonstrate Pygame sprites. It makes a 'fish tank' and fills it with random blocks, then drops a large number of random balls in it that bounce around off the walls, blocks, and each other. After they settle down enough they disappear and respawn. Balls are not perfectly elastic (they lose energy on bounces) and gravity and ball mass are taken into account for collisions.

I wrote this back in 2005 as my first Pygame program, and looking back, this is pretty naive, but I can still just watch it for quite a while. Basically I'm just uploading this as a simple code sample.

You can just go in and hack the settings in the config file at top.

Limitations are:

  • No sound.
  • Collisions are rectangular instead of circular.
  • Physics aren't real, just 'real enough', which means:
  • Collisions are treated as separate sets of two-body collisions, so overlap will occur when for example ball A and B collide, so bounce back, and C and D collide, so bounce back, but now C and B are overlapping each other. Then they're sort of stuck!


Home Page:


click to view original size


Bouncy Ball tank - 1.00 - Aug 27, 2008 account Comments

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

August 31, 2008 7:53am - F. Aschwanden - nickname: (tyger) - 5/5
Wow, I love it! This is a gem of physical gravitation and quite fluent (works fine on my Mac). You also took care that objects with more mass are not bounced back so strong. Saw some on then crowded floor, overlapping, not bounced, but thats no biggy.
This routine is a great base to create a clone like Wizball or any other bouncing ball oriended game.
Guys out there, watch it, its great!

our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
Nov 17, 2015

Nov 12, 2015

Nov 11, 2015

Nov 8, 2015

Oct 16, 2015

Oct 9, 2015

Sep 11, 2015

Sep 6, 2015

Aug 26, 2015

Aug 25, 2015

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