Our great sponsors
-
libtcod
A collection of tools and algorithms for developing traditional roguelikes. Such as field-of-view, pathfinding, and a tile-based terminal emulator.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Libtcod itself uses SDL2. It maps tile glyphs to a texture atlas and maps Unicode codepoints to tile positions. Then it has another data structure called a console which has the background color, foreground color, and codepoint for each tile on that console. It then uses SDL_RenderGeometry to quickly render the background and colored glyphs to an SDL texture, skipping unchanged tiles as an optimization, then renders that texture to the window. The C99 source is here: renderer_sdl2.h renderer_sdl2.c, a C++ version would surely look better.
Jeff Lait has a very no-nonsense homebrew curses-or-SDL emulator he uses in his 7drls. See eg. You only live once. The main logic is in gfxengine.cpp, and gfx_curses and gfx_sdl are the curses and SDL backends respectively. gfx_sdl.cpp is less than 500 lines of code, so these things aren't terribly complex. Simplest thing to do is probably just implement your own from scratch using something like this as the reference.
Related posts
- SRiC ("Simple" Roguelike in C) has stairs now, and multiple floors!
- libtcod roguelike C tutorial?
- The 7DRL Challenge 2022 is announced! Create a complete roguelike game in 7 days.
- WIP for PCG treasure maps. Top set are for the "world map" (very zoomed out, rivers, mountains, etc), bottom set for "local map" (specific tiles, e.g. on a volcano's side, inside a building, by a coast, etc)
- Finished my traditional roguelike. Play it and share feedback. AMA about the development