Official development blog

ASCII Particle Effects

With item stats out of the way, it’s time to start fleshing out item-related content. To that end progress is being made on three different fronts: Item art, weapon sounds, and weapon particle effects.

Procedural particle scripts are a great time-saving substitute for hand-drawn animations. They also lend a unique visual appeal to the otherwise minimalist-informative interface of a static grid-based world. All weapons will have their own particle effect, so you can pretty easily discern the type of weapon being fired (sound will also help in this regard) and we no longer require “X attacks Y” log messages--if you must have all the juicy details they’re still available via the separate and optional combat log.

When the old 7DRL version was born, it simply imported a large library of particle effects along with the X@COM engine. Due to time constraints all I could do was spend a few minutes recoloring a few of them, so in the end many weapons used similar effects. A few months back I took some time off coding to rewrite and expand that particle collection, giving it a greater variety of styles tailored to Cogmind. Because the final weapon list was not ready at the time, the designs carry generic labels--now it’s time to tweak the particles and assign them to specific weapons.

The current “official” set of generic particles so far contains:

  • 7 ballistic projectiles
  • 12 lasers
  • 4 plasma blasts
  • 5 rockets
  • 7 special launchers
  • 24 explosions

You can tell I’m fond of explosions ;)

These numbers indicate different “styles,” not an absolute number of effects, because a recolored variant of any given style can be created by adding a single line of script.

Here’s a composite screenshot showing a few different projectiles and explosions:

cogmind_particle_effects

A missile, explosion, plasma, and EMP blast.

The animations look better in motion:

cogmind_weapon_particle_effects_1

Minigun, followed by cannons and lasers.

cogmind_weapon_particle_effects_2

Lasers, plasma, and flamer.

cogmind_weapon_particle_effects_3

Rockets/launchers and explosions/EMP.

Like everything else Cogmind, the particles are controlled entirely via external text files like this one:

cogmind_explosion_scripts

The highlighted area is a script defining a single incendiary explosion. (click for full size)

The result of the script highlighted above is this explosion:

cogmind_incendiary_explosion

The base color of the explosion can be anything, as set in a single script variable.

Technical

Recoloring, or creating multiple variants of the same particle with slightly different behaviors, is simplified by templates. You can see them in the scripts above listed as red text containing the values to substitute. (Note: All those “TK”s are there because I haven’t yet associated them with any specific weapons.)

Just before the engine parses particle data, it checks for templates and automatically generates all applicable variants of each type of particle. Thus particle designs can be abstracted to their most general form (without specifying color, for example) for maximum reusability and minimal copy-pasting.

With regard to weapons, in most cases templates are simply used for recoloring particles. Templates are technically capable of substituting any kind of parameter--other behavioral adjustments such as particle speed and lifetime are more often used for creating multiple variants of interface animations.

From an implementation perspective, the coolest new feature of the Cogmind particle engine is that it can be dynamically loaded! This is a huge time saver. All particle data can be reloaded at the press of a button while the game is running, meaning we can tweak and edit particles in the text files and see the results immediately in game.

A lot of interdependent factors determine what a particle effect looks like, so creating/changing one can take a few tries. Having to make a best guess and restart the game with every tweak was getting really, really annoying, not to mention slow.

This entry was posted in Art and tagged , , , , . Bookmark the permalink. Trackbacks are closed, but you can post a comment.

2 Comments

  1. Peter Matejovsky
    Posted May 2, 2021 at 11:06 pm | Permalink

    Would you mind to provide more technical detail how particle system was implemented? :)

    • Kyzrati
      Posted May 3, 2021 at 7:05 am | Permalink

      Heh, yeah I get that question occasionally, but the answer is that there’s really not much special to it, since this was (and still is xD) my first ever such system, and all I did was follow basic online gamedev tutorials for how to build such an engine.

      Notice I don’t really share much in the way of technical details on my blog--it’s more of a design blog since all my technical approaches have been done better by someone else, and shared by other devs before (which is where I learned/copied it in the first place!). I mean no one’s built exactly this system before, sure, but it’s just a super basic system of particle objects that can be emitters and have velocity, color, etc. There are tons of detailed tutorials for this sort of thing, including code and in both basic forms as well as variants using much more advanced and versatile tech. A Google search brings up dozens upon dozens of them. I’d say do what I did and read a few of those, then apply their concepts to your game.

Post a Comment

Your email is never published nor shared. Only the anti-spam entry is required. See here for the privacy policy.

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>