Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Floxels are cute, but not very smart. They live in a maze, and their hobbies are hanging around in gangs, and converting other Floxels to their colour.


Play in browser or download for Windows/OSX/Linux:

Play on Android: Google Play, Amazon Appstore


Setting up

The game is built with libGDX. Set up your development environment following the libGDX instructions. Clone or download the repository, and import it into your development environment to build and run.


LibGDX allows the project to be built for assorted targets: Windows, OSX, Linux, Android, HTML, and iOS (although that's not been tried yet).

Project layout

The project follows the usual libGDX layout, with a main folder for the source code, and different folders to support building for different targets.

  • core - the main source code, common to all targets
  • desktop - specifics for desktop targets (Windows, OSX, Linux)
  • android - specifics for Android
  • assets - image and audio assets, common to all targets
  • html - specifics for HTML
  • ios - specifics for iOS (untested)

How it works (the science bit)

Floxels behave according to a mash-up of half-remembered bits of physics, hacked together with no aim other than to give a nice-looking effect.

The starting point is to fill the maze with an invisible fluid. The fluid is incompressible, simply amounting to a two-dimensional velocity field subject to a divergence-free constraint (for the most part) and boundary conditions at the maze walls. The boundary conditions might be expected to say that no fluid flows through the walls, but in fact having a bit of an in-flow everywhere keeps the Floxels from hugging the walls. In effect, extra fluid is being continuously pumped into the maze through the walls, which seems unphysical, but doesn't cause any problems mathematically.

The fluid's velocity field is calculated by solving Poisson's equation for the given boundary conditions. The solution of the equation is a potential field, and the gradient of that is the fluid's velocity field. The equation is solved at every time-step of the simulation by the multigrid method (with Gauss-Seidel smoothing). Usually the numerical solver would iterate until the solution converges, but in this case we apply the scientific principle of "it's just a game, no one cares" and save a lot of computational effort by only doing one iteration.

The Floxels themselves are particles that float (advect) in the invisible fluid. They take on the local velocity of the fluid, and go wherever the flow takes them. But the Floxels also influence the behaviour of the fluid in a way that pulls them (or at least the ones with the same colour) together into clumps.

The Floxels are charged particles, although not quite following the traditional 'positive' and 'negative' roles. Each one has an 'attractive' charge that pulls other Floxels (of the same colour) towards it. To avoid all of the Floxels pulling each other together into a single tiny clump, the attractive charge is spread over a small area around each Floxel, with a smaller 'repulsive' charge at the centre. This makes the Floxels huddle together while still respecting each other's personal space. (This balance between attraction and repulsion is similar to how nuclear forces hold protons and neutrons together in the nucleus of an atom.)

The charges from the Floxels create an electric field through the maze. At this point the laws of physics all go a bit wonky. As it happens, electric fields obey Poisson's equation, which is already being used to generate the fluid's velocity field. Not wanting to let a good coincidence go to waste, the Floxels use just one field for both the electrostatics and the fluid flow, despite physics claiming that these are completely different things. Each Floxel adds its attractive and repulsive charges as source terms to Poisson's equation for the fluid's velocity field (breaking the original constraint that the fluid flow should have zero divergence). This seems horribly, horribly wrong, but actually works quite nicely. In effect, an attractive charge causes fluid to be sucked out of the maze, pulling in any nearby Floxels, while a repulsive charge cause fluid to be squirted into the maze, pushing Floxels away.

That's how things work for a single-coloured population of Floxels. With two different colours of Floxel, the maze hosts two different fluids, one for each population. The fluids don't interact directly, but Floxels of one population appear as charges in the fluid of the other population. Usually the two populations of Floxels behave like predators and prey, with the prey Floxels adding attractive charges to the predator fluid, and the predators adding repulsive charges to the prey fluid, meaning that one population runs while the other chases.

When Floxels of different colours get close to each other they fight, but there's nothing scientific about that.

Finally, despite the Floxel simulation having originated through such a shameless misuse of scientific concepts, it's interesting to see that more deliberate work on crowd modelling actually uses some similar techniques, in particular constructing potential fields for different populations within a crowd to determine movement direction.


Part game, part science-experiment-gone-wrong








No packages published