This week, I implemented acid and fire! So now you can use acid to eat away the terrain and fire to, well, burn things.
And you can do those things to moving bodies too!
Plus: where there's fire, there's smoke1 - so now there's smoke too.
Acid's Ire
Acid is a special kind of liquid atom that damages atoms next to it:
Only some atoms have any health at all, and atoms with no health are basically invulnerable, so for example you can't use acid to destroy water.1
Each acid atom has a certain "charge" that's consumed when it damages an atom, and the acid atom is destroyed when its charge runs out.
At the moment acid preferentially eats whatever it is on top of, but it will also eat sideways:
Burning Fire
Fire is implemented as a special type of atom, which does 2 things:
- every so often, they find a "combustible" atom around themselves to "set alight" (by spawning a new fire atom).
- every so often, they spawn a new fire atom above themselves.
And if there's nothing to burn, a fire atom will just move upwards immediately, so it looks like this:
There's no concept of temperature2, so instead the color change is done based on much fuel the atom has consumed recently - and of course if no fuel has been consumed recently, the fire atom is destroyed.
Fire also needs air to burn, so you can smother it:
Fire isn't properly put out by water yet though (except for the smothering), because I haven't implemented steam.3
Smoke
When a fire atom runs out of fuel, it turns into a new 'smoke' atom (as already shown above), which behaves like a gas.
Gases are implemented as the simplest possible thing: gases are liquids but with slightly tweaked movement parameters4, the most important of which is that gravity is negative!
Of course gases are also less dense than liquids so water will displace smoke.
Smoke also "diffuses" into air over time, which is a fancy way of saying that after a timer expires I destroy the smoke atom. (Factorio players: no, I'm not making smoke get absorbed by trees!)
Corroding and Burning Moving Bodies
Since each moving body is composed of (wood) atoms, you can corrode moving bodies too:
The way this works is that each atom interacts with atoms from the moving body, and if any atoms in the moving body have been destroyed then the colliders are regenerated using the same process we've discussed many times before.
The damage taken by the atom is then propagated to the moving body; regular moving bodies don't do anything with their damage yet5, but in future I'll use this to damage the player and enemies.
You can also burn moving bodies, mostly:
It works, but it doesn't work quite as well as it should:
- Burning atoms aren't inherently recorded as "on fire": they just get their health reduced by fire that's nearby. So when a moving body moves, then a burning atom can be moved away from the fire.. which means there's nothing burning it anymore.
- Smoke is not "air", and therefore having lots of fire atoms be emitted means lots of smoke atoms being created, which means a lack of air - so fire tends to put itself out.
- Each smoke atom exerts a tiny bit of force on bodies that displace them, and I haven't got the force calculation quite right yet. When it's a large body, everything is totally fine, but bodies of only 1-10 atoms can get yeeted (a technical term for "flung really fast") really far away sometimes, which in practice makes it look like those bodies suddenly disappear.
- Really tiny bodies are really difficult to set on fire. Maybe because atoms on the bottom of a moving body sometimes overlap a tiny amount with the atoms that make up the surface that the moving body is resting on? That would prevent those atoms in the moving body from being placed into the world, which in turn would mean they can't be burned (because they're never next to any fire atoms).
I'll fix those things later at some point.
Corroding and Burning Players?
You can't.
Okay, okay, technically you can set a player on fire because the game currently pretends a player is technically made out of a moving body (as discussed last week), and all moving bodies are currently made of wood.
But player characters don't have health yet so it doesn't do anything interesting.
Playable web build
Go corrode and burn some things:
I improved controls a little too:
- Erase by holding right click.
- Change the brush size with the mouse wheel.
- Zoom in and out with your horizontal mouse wheel (if your mouse has one).
I know, I know - but look, corrupting proverbs is fun.
What should water and acid do? You tell me what you think!
Or at least, no concept of temperature yet. I haven't yet thought of a good way to have temperature impact gameplay so I probably won't implement it until I can think of that.
Steam-the-gas isn't hard to add, but what do you do with the steam once it's in the air? Presumably it needs to condense back into water at some point - based on temperature, presumably? Still mulling over how to do that so I haven't gone down that rabbit hole yet.
Although actually adding support for tweaking movement for different types of atoms was a relatively large reorganization of how atoms work, so it's only simple from the outside.
Though you could imagine that a moving body of a certain type that takes a lot of damage from various sources might suddenly shatter, or something like that.