Black Future
I’ve thoroughly enjoyed lurking in this subreddit for a long time, and now I feel like I have something to contribute! Black Future is more of a tech-demo than a game at this point, but it’s coming along rapidly so I thought I’d start sharing. I’ll roll out more concept/themes as things progress, for now - the tech side of things!
The system is written in C++ (C++14, I like make_unique too much), and currently compiles/runs on Linux and OS X. I’ll do a Windows build when C2 comes out, with all of the clang goodness on the Windows platform. It currently requires ncursesw and SDL to build. You can find the source/build instructions over on my github repository: https://github.com/thebracket/bgame
Rendering Back-end. I setup a “virtual console” class that allows higher-level classes to write to a virtual screen without knowing the details of how it will be rendered. This sits atop a set of back-ends; currently, the game supports SDL (with truecolor), raw ANSI escape codes (also with truecolor) and ncurses (currently only works in the 8 color/64 palette entries mode). Input is gathered via these back-ends, and fed into a device-independent input system (which is very much a work in progress). This makes it relatively easy to build and run on various platforms I’ve played with, from SSH terminals to SDL windows. For now, it’s all DOS code page ASCII/ANSI graphics - but I’m trying to keep it easy for myself to add tiles later if I wish.
On top of that, there’s a simple GUI Framework - frames (with layout assistance based on terminal size) which also implements a handy multi-color text console. I’ve used it for the main menu, worldgen display and actual game rendering - it’s not complete, but it’s a pretty solid start.
My next step was world generation; I’ve had some fun with this! The game eventually should cover a pretty large geographical area, so I broke up the world into “landblock” chunks. However, I needed these to tile seamlessly - so world generation starts on a global scale, and then works down to individual tiles. Step 1 simulates a few thousand “fault lines” (increase or decrease elevation in a line) across a height map, which are then smoothed. Step 2 looks at the resulting altitudes, and floods the map - ensuring that 1/3 of the map is water. Beach outlines are then marked, and I used the venerable “marching squares” algorithm to trace along the edges of contour lines and mark them to receive “up ramp” tiles. Step 3 generates a temperature gradient map, with a random element and adjustment by altitude (colder at higher altitudes). Finally, step 4 bakes all of this into tiles for each landblock. A tile considers its type (flat/beach/ramp from stage 1), altitude and temperature in determining what it should become. For example, temperate/flat tiles may end up as shrubs, grass, wild-flowers, etc. Tiles also store their “upwards surface normal” - that is, angle point up on an east/west basis.
Next up, there’s the beginnings of an entity component system. I’d never written one of these before, so it’s probably a long way from perfect, but it’s already bearing fruit: it’s been wonderfully easy to plug all the other components/systems in to get this far. Right now, there’s a really primitive “AI” component that simply wanders randomly, a “viewshed” component for determining visibility from a location, and of course position and renderable components - and systems that use them.
Next up, we have the lighting system. It’s designed to grow into a lightmap system (to allow me to play with stealth, floodlights and similar) - but for now, it’s a simple time-of-day based lighting system. The sun’s approach angle is compared with the slope of each tile, and that tile gains a light-level based on the result (it’s pretty close to Lambert shading, but nowhere near as detailed).
Plugging all this together, and throwing in a quick “calendar” component to handle time-of-day, you get a pretty pleasing tech-demo of my basic low-level engine: Hyperactive @ Symbols
I’m hoping that as soon as I finish the serialization code that goes with the existing entity-component system, I can get into some actual game work. :-)
Original: https://www.reddit.com/r/roguelikedev/comments/3pxqy4/sharing_saturday_73/