pygame is
Python
Simple DirectMedia Layer
 
 
pygame.org is
Site Swing
Bouncy Ball tank

Bouncy Ball tank - 1.00

Ron Dippold (sizer99)

Tags:

Description

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!

Links

Home Page: http://sizer99.com/wavy/
Source: http://sizer99.com/wavy/bounce.zip

Screenshot


click to view original size

Releases

Bouncy Ball tank - 1.00 - Aug 27, 2008

Pygame.org account Comments

If you wish to leave a comment with your pygame.org 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!
spotlight

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


Apr 19, 2014

Apr 16, 2014

Apr 13, 2014

Apr 9, 2014

Mar 18, 2014


Mar 15, 2014


Mar 14, 2014

Mar 13, 2014

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