Foxfire Fridays #2
This Foxfire Friday was originally posted on Twitter here.
Hello everyone, welcome to #FoxfireFridays number 2. By tradition, Foxfire will have you manage light in order to see different places. For debug purposes, instead of completely hiding things you can’t see, these screenshots have them darker.
But, Foxfire uses a more sophisticated algorithm than most roguelikes. First, sunlight is added to the map. Then, all the “emitters” on the map are polled every tick, and rays are cast from them to figure out the intensity at each tile … and the intensity of each ray is reduced by any “occluders” they may hit until they reach the edge of the loaded area or have intensity 0.
Because there’s inv-square falloff, pools of light merge, like metaballs.
There is supposed to be a video of two pools of light merging here, but I can’t manage to get it as a gif. Check the twitter thread if you want to see it.
The player’s viewshed is calculated similarly; rays are cast to each tile in the current zone, occlusion is summed along that ray, and the intensity against that tile is compared against any sense-providing mechanisms the player has.
Speaking of mechanisms, the player (and all robots in the game, eventually) have onboard, customizable logistic networks. Here’s an example one.
So, electricity flows from the fusion reactor to the battery, and then to the camera, the lamp, the Hall Effect sensor, and the “waste money” (which doesn’t do anything and just consumes electricity for test purposes.) And you can en/disable mechanisms too!
Speaking of, what happens if we turn on the Hall Effect sensor …
… wait, why is everything washed out? Take a look at the status bar; we’re in a very powerful magnetic field of over 1 Tesla. The hall effect sensor is washed out!
Normally this would white-out the screen and obscure things like being in total darkness would, but again I’ve kept things rendering for display purposes.
The lamp we have is also emitting a magnetic field. So if we turn it off …
… that’s better!
This sensor works anywhere from 20 microtesla to 5 millitesla. Earth’s magnetic field is 30 uT, so we can see by it! Notice how we can see through the wall of the building in the last screenshot. That glowglobe there also emits a magnetic field, so it can wash us out too.
Finally, there’s a bit of world-generation now; specifically, a biome map. And, a cute little loading screen! But every zone still just generates one rectangle … so I’ll show you my progress on worldgen next Friday.