Catch
Catch is a simple game that I used to explore multi-threaded games. It turned out to get good reactions from my friends, so I decided to put it online. The goal of the game is simple: keep as many of the multi-colored orbs on the screen at a time.
Enjoy: Catch.zip
Technical stuff: Behind the scenes, the orbs run a simple flocking algorithm and the cursor create an attractive force within a radius around it. As for the multi-threaded part, updates and object interaction are based on message passing which allows the update portion of the main loop to be multi-threaded very efficiently using a queuing system. The number of threads is set at compile time and is set to 4 right now. That seems to be a pretty good number on 2 and 4 core processors, but probably doesn't run too well one single cores. On a multi-core system, though, you can see the program is capable of saturating several cores, showing that it does indeed take full advantage of multi-threading (below there are links to versions built with more and fewer threads for comparison). Since I'm relying on Allegro for rendering, the render portion of the game loop is not multi-threaded, but it's written with a similar queue structure so it could be parallelized pretty easily if the renderer supported it.
If you're interested in comparing it's performance with different numbers of threads, you can try some of these other packages. I find that the performance differences start becoming very apparent somewhere around 1500 to 2000 particles, which can sometimes take awhile to get to. You can hit the T key in game to toggle displaying performance information (FPS and number of particles).
Some casual analysis: Here's some analysis that I did really quickly. It should not be taken as scientific, but it's at least interesting to see how the different versions above perform. This data was gathered on my laptop with a dual core, 1.73 GHz processor running Windows Vista. As you can see, there are performance improvements up to 4 threads, but going up to 8 threads doesn't make a different as the processor is likely already saturated.
 |
| Number of Threads |
FPS with 5000 Particles |
| 1 |
11.8302 |
| 2 |
13.8950 |
| 4 |
15.0687 |
| 8 |
15.0678 |
|
If you have any questions (technical or otherwise), feel free to email me.