Vincent's blog

GNU/Linux, tech and thoughts

Entropy, a HTML5 game with bouncing balls and simple physics

Python version

In my free time I wanted to try out pygame, so I created Entropy. It’s a game where balls are attracted or repulsed by the mouse cursor when holding the left, right or middle button. The balls also bounce against the screen edges. It is not a real game actually because there is no specific objective. Still, it is fun to move the balls around especially with 1000 of them. Additionally, it runs on the Nokia N900 and the accelerometer controls the gravity. The source code can be found here: Entropy (Python version)

Here is a video:

There are some configuration parameters in the “” file that can be adjusted.

Web version:

Then, I thought that no everybody would have Python and Pygame installed like Windows and Mac users, so I ported Entropy to Javascript and HTML5. Unfortunately, its performance was poor, so I added a WebGL renderer. Now it runs almost as smooth as the Python version !

If you have Firefox 4 or Chrome, you can try it out:

You can also check my games page which has more options.

For the web version, a few URL parameters can be appended:

  • “particles”: number of particles
  • “fps”: frames per second (defautls to 30)
  • “gravity”: “false” to disabled gravity. You can also hit the “G” key to toggle gravity.

Please note that the canvas content doesn’t resize automatically with the window, you have to refresh the page manually after resizing.

Have fun !

Edit: the code is now available on GitHub.

Comments are currently closed.