Frogatto & Friends

Frogatto sprite

Frogatto & Friends is an action-adventure platformer game, starring a certain quixotic frog.
We're an open-source community project, and welcome contributions!
We also have a very flexible editor and engine you can use to make your own creations.

Particle System “Pre-Pumping”

February 12th, 2011 by Jetrel

“Particle systems” are a common feature in modern videogames; they’re used to simulate a lot of natural effects, such as dust clouds, splashing water, and other effects where little chunks of solid, or puffs of gas are emitted. Wikipedia probably can save me a great deal of typing. Frogatto uses particle systems, albeit with hard-edge pixel-art sprites as the particles, for many effects in game, such as the sparks that fly off of torches, to the water spouting from a fountain, to the fireplaces inside houses.

A common problem with particle systems is that they only begin their “simulation” when the player-camera actually is pointing at them, in order to save on processing time (and likewise, they pause it after the camera shifts away). If you consider a fire that’s constantly burning, with a column of smoke coming off of it, you’d expect this column of smoke to be complete. But smoke takes several seconds to drift upwards, and if you only start “simulating” it the moment the player walks onto the screen, it will look odd- the sky above the fire will be empty, and the fire will start letting off smoke as if it was only lit the moment you walked onto the screen (since in the simulation, it was). The pausing is not a problem, since the column has fully formed, just the initial delay whilst the empty air fills with smoke.

For quick-moving particles (such as sparks flying off of a fire), this works fine, since it only takes the sparks a “blink of an eye” to fill their full range. However, we’ve kinda dragged our heels on putting smoke into the game because of how awkward it looks for smoke to only start flying the moment you walk onto the screen. This is kind of a shame, because I’ve had this smoke-emitter effect done for months now (part of it was just good old-fashioned getting forgotten amidst all the other stuff to be done, another part was speed concerns). Here’s a picture of what the smoke looks like:

So, I’ve come up with a fairly simple solution for particle systems. Since the mere simulation part of them is very gentle on performance (it’s only the actual drawing that’s expensive, unless I’m using a ridiculous number of particles), what we do is (for only the slow particle types that need it) we automatically simulate the first couple of seconds in advance. It seems to work like a charm – probably the biggest beneficiary will be the falling leaves in the forest, since they can take as long as 10-20 seconds to fall, and the player can easily leave the whole screen before they have a chance to distribute themselves across more than a tiny fraction of it. This may take a little while, since those are still being done as objects; I haven’t had time to re-implement them as a particle-system, in part because I’ll need to add the option of sinusoidal paths for the particles.

As a bizarre curiousity; neither warcraft 3, nor (quite surprisingly) even starcraft 2, seem to do this. If you pan over a burning building, the fires will begin as though it just started burning the moment you moved the camera there. I’m guessing something in the whole structure of their game makes it considerably harder to do; in frogatto this took a whopping 4 lines of code. Age of Empires 3, by comparison, does not have this problem.

FacebooktwitterredditmailFacebooktwitterredditmail

Graphics News #15

February 8th, 2011 by Jetrel

We’ve redone how shadows work, so that shadows blend an even amount in all directions.

Also, for interest’s sake, here’s an image of what it looks like when our shadows are blending with just gray, instead of blending with that purple tone. It’s considerably more lifeless; grey would seem like the “safe” choice, but in nature, the color-components of lighting on a shadowed area are often different (for example, the lighted side of an exterior setting is often lit with yellowish light, and the dark side with blue+green light). Purple just looks better in this situation.

FacebooktwitterredditmailFacebooktwitterredditmail