This is Cosmosphere! You play as a colorful low-poly blob and can roll around a small area with a bunch of cosmopheres bouncing in place. The objective is to simply collect more cosmopheres than the AI controlled opponent blob. This is all happening with the thrilling tune of the NES Bubble Bobble theme song playing in the background.

Under the hood

The underlying engine is the powerful open-source irrLicht engine. I had previously tried to use GLFW mixed with OpenGL, but setting up the window, fetching input, and handling all the nuances they entail took my time away from building the actual physics. irrLicht on the other hand, handles all the dirty work of rendering and offers the use of DirectX 9, OpenGL, software and hardware rendering, making it a breeze. Now at the end of the project, my engine contains support for rods, springs, bungees, cables, gravity and other force generators. Collisions are also handled on a particle to particle and particle to ground basis.

The blobby process

Cosmosphere was an attempt to create a game similar to LocoRoco and World of Goo. In these games, particles are connected in ways to simulate amorphous blobs and other complex objects. To begin, I needed to structure my own set of particles in a sphere and link a mesh around them.
I had previously written a procedural sphere mesh generator, similar to this StackOverflow answer, and felt it was perfect for the situation. Creating a custom mesh in irrLicht is as simple as passing a list of indices and vertices to a draw3Dprimitive() function. My idea was to create a particle for each unique vertex position in the sphere. I say ‘unique’ because a vertex cannot be shared by more than one triangle, so multiple vertices are created at one point in space. This can be seen in the crude example to the left.
To remedy this, I made a list of unique 3D locations used by the vertices. All I had to do was then create a particle at each of these locations. After wrestling with other silly issues, I had a full sphere outlined with my particles as seen to the right.

The next challenge was getting the sphere mesh to update. Given that I had a list of unique vertex positions, I created a map to link vertices to a specific particle index. So for each frame, the vertices would align themselves to their particle counterpart. The first iteration created the funky looking blob as seen below.



Now you may tell yourself, “Hey that doesn’t look like the blob in the video”. Well you would be correct, it’s not. You probably noticed in the above gif, the bottom of the sphere clips into the top as it falls. In order to keep the shape of the sphere, the particles need to be connected by some rods and springs. If you re-examine at the spinning particle sphere gif, there’s quite a large amount of particles that make up the sphere. If we were to connect these particles in such a manner that the sphere would never collapse, the rod count would be in the hundreds. This is simply not affordable with two blob entities on screen updating each frame. I was forced to cut the amount of primitives significantly in order to keep the framerate consistent.

Play game

If you have a windows machine and would like to roll around for yourself, grab the game here! The controls are simple: WASD to roll, hit space near a cosmosphere to link it to you. If you would like to spawn more particles, go into the assets folder and open up config.xml. Then change the particleCount to whatever you wish.