I Accidentally Built a Particle System in FoxPro.

When the player died in Defender, the ship seemed to completely disintegrate. It wasn’t just an explosion graphic being shown for a few frames. Lots of individual pieces flew out across the screen.

So I thought I would see if Visual FoxPro could do something similar.

The first attempt uses 80 tiny FoxPro shape controls. Each one has its own position, speed, direction, colour and lifespan. FoxPro recalculates and moves all of them every 30 milliseconds.

And it works.

For a first attempt, it actually looks pretty awesome. Especially when you remember this is Visual FoxPro, a database development language from the 1990s.

What I hadn’t realised when I started is that I wasn’t only creating an explosion.

I had created the beginnings of a particle system.

By changing how the particles are launched and moved, the same code could now be used for all sorts of effects:

  • Sparks coming from a damaged ship
  • Pieces breaking away from the shield
  • Smoke and glowing embers
  • Particles spiralling into a portal
  • A power-up being absorbed by the player
  • A hyperspace effect
  • Sparks falling from BARF’s console while he insists everything is working perfectly

At some point I may replace the FoxPro shapes with GDI+ drawing, which would allow more particles, transparency and glowing trails.

But for now, Visual FoxPro is happily throwing 80 individually calculated pieces of spaceship across the screen while also running the game.

I only wanted a better explosion.

It appears I may have accidentally built an effects engine.

Bleedin Nora!

Leave a comment