Killed enemies now turn into physically-simulated corpses!
Finally a use for all that work to marry two physics engines together - phew.
The Anti-Fun Hitlist
Killing baddies is supposed to be fun, but right now it's not that fun yet.
I made a list of all the reasons why:
- there's no feedback for attacks/spells that hit (no blood, enemies aren't knocked back, etc)
- there's no reward for killing enemies (vs bypassing them)
- there are no sound effects (for spells, enemies getting hit, enemies dying, fire burning, etc)
- etc
You get the idea - it was a long list.
Ragdoll Corpses
One item on the Anti-Fun Hitlist was that dead enemies just disappear - no corpses, no death animation, not even any particle effects.
So, corpses: should dead enemies just flip on their side and that becomes their corpse (like Broforce does)?
Nah, it seems cooler to have dead enemies physically slump down if they get killed (like in Noita):
Implementing Ragdolls
As always, I copied Noita's approach: first, take your regular enemy sprite:
Step 2: manually split it into different pieces, one for each "ragdoll bone" (like a limb):
Step 3: automatically figure out where bones are meant to connect to each other, based on overlapping pixels between bones:
Step 4: when the enemy dies, create those bones as moving bodies, set the colors of each atom to match that of the pixel and connect them up per the joints!
I also made a small refinement to allow some bones to be totally detached, so that the bow and quiver of a goblin archer could fall to the ground separately.
(Sometimes) On Fire
Since I've been using fire to kill the enemies, you may have wondered - shouldn't the enemies' corpses be burning?
The answer is Yes. (That's very astute of you to ask that question.)
But unfortunately, fire doesn't reliably burn moving bodies right now,1 so even though each moving body is made of burnable wood,2 your fireball spell will only actually set the corpse alight maybe 20% of the time.
So, fixing fire is a new entry on the Anti-Fun Hitlist!
Playable web build
Chuck some ragdolls around here (press G to use the grabbing tool on dead enemies, and - reminder - Tab, Tab to cast a little fireball spell):
Because fire is implemented as atoms which feed on nearby atoms, and so if a moving body moves slightly then it may no longer be next to the fire that's burning it. The fix will probably be to make "is on fire" inherently part of an atom's state.
Yes, I know. Most hounds and goblins we know are made of flesh, not wood. But you can't really tell the difference because there aren't any sound effects based on atom material right now anyway.