Work continues apace on my book (no release date or even title, yet - I’m NDA’d, but I can say that I’m working with a publisher to write a book about learning Rust through game development. I’ll announce more when it is further along!).
RLTK_RS - Roguelike Toolkit for Rust | Github | Crates.io
I’m continuing to work with Jice on merging doryen_rs
into bracket-lib
, which means ensuring that the library supports everything his library needs. It’s coming along nicely, we’re down to a few smaller issues on the to-do list! I won’t push a new crate release until it’s done, stabilized and tested (and any changes needed by the tutorial are ready to go).
- Fixed an issue with black text on a white background in the WASM renderer (Thanks
OlverUv
for finding it!). - Merged a PR (also from
OliverUv
) that lets you pushTextBlock
s to the batch rendering system. - The Input API is done and merged! The context object is now tiny: it doesn’t contain any of the library, just a snapshot of recent input.
- If you include
with_advanced_input
in your builder list, it starts gathering events (which you can read individually or batched) for event-based input (very similar to an SDL2 setup). - There’s also support for
key_pressed
andmouse_down
, which is latched (so you are informed once on down). - You can poll mouse position by pixel, or character on a terminal.
- You can access keys by
VirtualKeyCode
or scan-code. I went ahead and captured scan codes for my entire keyboard, and added them intocurses
andcrossterm
(I couldn’t find a good way to get the code). - If you are using native OpenGL, there’s quite a few more events available (such as minimizing and focus), since I have a full
winit
event stream at my fingertips. - If you are using Amethyst as the back-end, it internally uses their
EventChannel
system - so there’s very little overhead. - The other back-ends do a bit of magic to emulate the event queue from their own systems.
- If you include
bracket-color
now supports RGBA as well as RGB. There’s fullFrom
support for converting between the two with a simpleinto()
call.bracket-terminal
'sBTerm
(the context it sends each tick) has been separated from theConsole
trait. This sped up compilation a bit, and allowed me to implement a lot ofInto<X>
conversions on the console commands. In particular, everything that took anRGB
now takes anRGBA
- but thanks toInto<RGBA>
it will still compile with your old code (and default to a solid alpha).- Some helpers have been added to quickly set the entire foreground, background or both alpha levels for characters on a console.
- The graphical (OpenGL, WASM, Amethyst) render targets now support alpha channel! You can use alpha in your font files, or you can specify alpha by character. If you want to fade in text on layers, now you can. :-)
- You can now set an arbitrary clipping window on any layer with
set_clipping
(it takes anOption
- sendNone
and it goes back to clipping only at the terminal boundaries). - There’s a whole new
VirtualConsole
system. Setup the console to any size, and draw to your heart’s content. Then you can render it to a physical terminal, specifying “window” dimensions for source and destination. The relevant portion of the virtual console is applied to that terminal (sparse or simple). This is really handy for embedding your manual and letting the user scroll through it, or you could use it to create UI elements and draw them when needed. Virtual Consoles are not attached to the context - you can do whatever you like with them, and submit them for rendering (via a batch or direct) when you need them. - Added a helper to create a
VirtualConsole
from a big blob of text. Word-wrapping doesn’t work yet, but line-wrapping does. It reads the text, parses it into lines and calculates line-wrap. It then makes the console size equal to what the text file needs. - New functions for right-justifying printed text.
- New functions for centering text on an arbitrary point.
bracket-color
now supports (via a feature flag) palettes. You can save named colors, and access them when needed.- New inline color specification. With the new
printer
command, you can embed colors (from the palette) in strings. You can also specify alignment in the same call. This is straight out ofdoryen_rs
(thanks, Jice!). A call toprinter
with the string#[blue]Hello #[pink]Bracket#[] world.
will print “Hello” and “world” in blue, and “Bracket” in pink.
Examples
- The Tiles Example now benefits from built-in alpha blending.
- The ugly color font example demonstrates using a font file with multiple colors baked into it, and a gaussian blur to apply Alpha to the edges of the font characters (giving a smooth, fuzzy look). It uses a Virtual Console to render part of A Tale of Two Cities - the text is automatically mapped to the console from plain text.
- Hello Terminal has been updated to use the new inline color system.
- Input Harness shows off the new input system. Watch your browser’s message console - it shows all of the events being generated, as well as the program showing current input state.
Rust Roguelike Tutorial | Website | Github | Twitter
More bug-fixes from users! Several PRs, and a few fixes. In particular, fixed a doozy of a bug (affecting chapters 9 through 60) that prevented multiple sources of damage from affecting an entity in one turn.
I’m still working on the next couple of chapters (to be released together), but time has been short.