Sharing Saturday 302

· ☕ 3 min read

It’s been a week of meetings, but I still feel like I got a lot done!

RLTK_RS - Roguelike Toolkit for Rust | Github |

The back-end work required for doryen_rs to merge with bracket-lib (and use my library as their back-end) is done! After a 2-week sprint, we managed to get everything “jice-nospam” needs working. :-) The Doryen library is pretty nice, and comes with a beautiful CP437 demo. I wish I was that good at making ANSI art!

  • bracket-color now supports RGBA. There’s a bunch of Into setups in the main library to ensure that your old code works (you can still drop in an RGB color and have it converted if you don’t care about alpha). All the support services such as lerps, greyscales, HSV conversions and similar are working and tested. The render system now supports alpha-blending across layers. WASM demo
  • Rectangle-based sub-clipping is now supported. So you can specify “clip to this rectangle”, and whatever you render is clipped to that region only.
  • A new CharacterTranslationMode setting lets you pick if you want your characters translated to CP437 glyphs, use Unicode glyph values (u16), or do it yourself via a function. This lets you work with different fonts more easily.
  • You can switch fonts in a terminal layer at run-time. WASM demo
  • You can change the dimensions of terminal layers at run-time. Unfortunately, every time I ask Windows to resize the window (via winit), the whole thing crashes. So for now, it just re-scales the fonts. This is native/local OpenGL only for now.
  • The fontloader is smarter: if your font file doesn’t have an alpha channel, it adds one for you. You can specify a background color to act as a mask (great for the old “pink background” fonts), or it defaults to black. Providing your own alpha-friendly files is generally a better idea.
  • (Native GL only) There’s a command to save screenshots.
  • The entire OpenGL back-end has been refactored to be shared between WASM and Native GL. So I’m only writing the display GL display code once now. The library shrunk considerably as a result. :-)
  • New “fancy” layer type. (I plan to rename it, but I’m struggling to find a good one). It’s still a grid, but you specify glyph position as a float: so you can use the fractional part of the number to smoothly transition between tile locations. It also supports per-glyph scaling, rotation and z-order. Here’s a WASM demo of a bouncing @.
  • New “sprite” layer type. For this one, you specify whatever dimensions you want to pretend your console has - and apply sprites within that coordinate space. Sprites support alpha, z-order, scaling (rotation soon, but I kept running into problems with my math). Here’s a WASM demo of 100 dudes moving randomly
  • All console types now have an option to not have a background - so tiles won’t have their background color applied to “empty” pixels. This lets you put a graphical layer at the bottom with text on top.
  • (Thanks to OliverUv for finding this). Added benchmarks for A*. Discovered that using vec::with_capacity in the get_available_exits code you implement to interface with it gave a 16% speed increase. Replacing the vector with a SmallVec (a vector that stays on the stack for a small number of entries - defined at compilation time - but can still grow to the heap if it overflows) yielded another 8% performance improvement on top of that!

Rust Roguelike Tutorial | Website | Github | Twitter

Just a couple of little bug fixes this week. I have a backlog, and plan to tackle it very soon.

Share this post
Support the author with