Sunday, April 20, 2025
spot_img

Adventures in Map Zooming, Half 2: Engine-level Structure


Taking a special tack from final time, I made a decision that it could be price getting actually soiled with low-level engine work for the subsequent try at map zooming. One of many primary causes we’d have to go this route if there’s ever to be hope of cheap efficiency in software program mode: Soiled rects. If we play by the engine guidelines we get to maintain that performance in its current easy bundle, which typically means large financial savings on CPU cycles.

REX

It had been some time since I’d accomplished any critical tinkering in “Rogue Engine X” (REX), Cogmind’s underlying recreation engine. The acronym you would possibly acknowledge from REXPaint, the engine’s ASCII portray software program I constructed with it for my very own use and later launched (dang that’s been out for over 10 years now, too, with a lot of its personal customers).

I do very sometimes add a little bit REX performance right here and there to cater to Cogmind wants (or REXPaint for that matter), but it surely’s been mature for like 12 years so there’s by no means been any enormous developments in that point.

My plans this time have been for a reasonably large one: Add a 3rd sort of glyph measurement.

To summarize, in conventional terminal fashion the show is only a uniform grid of monospace glyphs, every with a foreground and background colour. Much less conventional, and wanted to provide Cogmind’s map with sq. areas versus rectangular ones extra acceptable for textual content parts, two adjoining textual content cells may be occupied by a single “broad” glyph.

rex_terminal_grid_demo_narrow_vs_wide

The idea is straightforward, although does require that textual content characters take up about half the width that tiles do, which is usually a little restrictive at sure sizes.

So the terminal has a base cell measurement, although doubling the width of that base measurement provides one other wider sort of glyph that can be utilized as properly. (I additionally shared a bigger diagram and a few associated concepts underneath the part “combined fonts” in my Fonts in Roguelikes article.)

cogmind_terminal_grid_demo_narrow_vs_wide

Discover how the tiles on this Cogmind screenshot every occupy two cells, delineated by the partial grid overlay.

In observe it will get a little bit extra sophisticated than one may think from the above description, as a result of glyphs aren’t drawn instantly and instantly to the seen console as proven, however as a substitute first drawn to their very own subconsole, and quite a few subconsoles can overlap each other at completely different positions. That is nice for organizing an interface, although when it comes time to merge all the pieces to create the ultimate view, partial overlapping means you’ll be able to have items of bigger glyphs displaying via, and many others.

The concept is to now add one thing even larger than broad glyphs, however a key level is that no matter the brand new dimensions are they have to nonetheless be a a number of of the bottom cell measurement. We have now the common base cell measurement used for textual content characters, a large glyph measurement used for map tiles/characters, and what can we extrapolate comes subsequent for a zoomed map if we would like it to retain a sq. side ratio? Enter: the quad.

rex_terminal_grid_demo_quad

Massive chonker tile has arrived.

Doubling the map tile measurement turns 1 broad tile into 4 (2×2), so whereas a large cell occupies two base cells, a “quad” glyph would occupy 8 base cells, 4 within the first row and 4 in a second row. This habits is just like the broad glyph, simply wider, whereas additionally increasing in a second dimension as properly, so introducing it to the engine logic is, uh, enjoyable 😛

I needed to rewrite many of the broad glyph help with a purpose to add quads, however having broad help already there to reference was useful, and merging all the pieces underneath the identical umbrella saved the general complexity from increasing a lot.

To design and check quads I loaded up my previous REX testing setting, which accommodates a random assortment of little check consoles and habits samples to make sure all the pieces is working correctly. One of many necessary issues to check past primary performance (which itself took a short time to get down) is quad overlap with different consoles of various sorts, and display edge overlaps.

rex_testing_console_quads

Been a few years since I used this factor! It was put collectively because the engine options have been coming collectively again in 2011 (my first publish about it).

Among the setting is animated/dynamic, although with quads it’s extra about rendering and alignment points, and confirming that underlying information values are appropriate.

I acquired fairly excited seeing the quads showing usually every time a brand new check was devised and (lastly) handed.

It’s official: REX has quad help!

Fonts

REX/Cogmind/REXPaint/and many others use bitmap fonts, so if we’re including a brand new glyph measurement meaning we additionally have to accommodate that measurement within the font information.

Whereas I enable quad fonts to be loaded from file, and that’s what I labored with for the preliminary implementation, it appeared pointless for our wants so far as offering this zooming function in Cogmind, since our primary purpose is to easily enable the upscaling of map tiles. Due to this fact one other a part of this engine rework was to permit quad bitmaps to be generated as wanted. Principally quads don’t should exist till a given font set is definitely set for use, at which period the bitmap might be generated in reminiscence by upscaling a specified supply bitmap which has already been loaded.

Cogmind

Then there’s Cogmind over right here not having any concept what’s about to hit it. Hm, what’s going to the influence be? My first fast check was to easily swap the map font to a quad and simply… see what occurs!

Effectively for essentially the most half it Simply Works. Wow. No crashes, simply huge tiles.

There’s some apparent kinks like the truth that I didn’t even change the map view dimensions, inflicting the map view to additionally quadruple in pixel measurement and lengthen off behind the HUD and off display, due to this fact “centering” Cogmind within the backside proper nook. That’s to be anticipated, together with different points like console alignment and some other supply code references assuming the map view is utilizing wide-type glyphs.

However the necessary factor is that IT WORKS.

cogmind_zoom_map_first_sample

Cogmind’s very first use of the brand new “quad” glyph help added to REX.

That ain’t no mockup. Additionally as a result of it’s taking part in by the engine guidelines there may be zero efficiency hit from this function. Zero.

You’ll be able to see the UI jank–to file that I needed to flip off autocentering and use the mouse for directional enter, plus the misalignments and bizarre stuff in varied areas (try the gadgets within the stock xD). BUT IT WORKS.

There’s clearly nonetheless so much to do. Manually check swapping the font is actually all I’ve accomplished to this point on the Cogmind facet of things–the measurement can’t but be toggled dynamically, however earlier than beginning this entire journey I did show it may work in principle by testing whether or not the sport would explode if I attempted to destroy your complete primary map interface and recreate it on the fly.

The disparity between the encircling UI textual content measurement and map tile measurement when zoomed is sort of annoying–it’s not fairly the identical aesthetic, but when it means some individuals who in any other case may not be capable to play may now accomplish that, I suppose that’s factor! Additionally once more I discover myself questioning what portion of potential gamers will discover this ample because it doesn’t tackle textual content, however perhaps together with the Terminus font it should work for most individuals. We’ll simply have to search out out.

Whereas doing the most recent map zoom experiments I additionally got here up with an preliminary checklist of complementary function concepts, those who may assist blunt the unfavorable impacts of getting a a lot shorter view vary than ordinary.

  • Cogmind could not essentially be centered when zoomed, as a substitute having the view steadily shift so to see additional and additional in your basic course of journey, out to your precise sight vary. Cogmind’s unmodified sight vary (16) whereas actually centered in a zoomed view would lengthen at most about 4 areas out of view within the worst case scenario–a north/south course, so Cogmind would typically be inside that distance of the middle except sight vary is additional boosted. (East-West course is much less of a problem for the reason that view is a horizontal rectangle for most individuals’s screens.) I can see this dynamic view positioning being pretty sophisticated to implement properly, however method and associated behaviors there may save the participant lots of time that will in any other case be spent scrolling round.
  • The above function is probably going extra acceptable for keyboard customers, not mouse customers who wouldn’t typically be pleased with a map typically shifting to a special place underneath their cursor throughout successive actions. For that sort of enter it could be good to have a method to rapidly set your personal relative centering place, relying on the course from Cogmind you want to see extra of whereas shifting or performing different actions.
  • Labels for necessary issues, particularly hostiles, that enter FOV however aren’t at the moment in view may be proven on the fringe of the view of their course. Or maybe not the entire label, however extra just like the floating indicators that seem to indicate an offscreen drone or Cogmind location. Cogmind already stops and labels new hostiles, so this might simply be an extension of that function to accommodate zoomed people who wish to have a little bit extra data in regards to the trigger. Heck, perhaps in quickly pausing the motion it may even shift the view over a bit to instantly see the trigger?
  • For brand new gamers, zooming the map may maybe assume they want all the pieces to be bigger or extra readable, during which case perhaps it’d be a good suggestion to additionally routinely swap the font to Terminus on the identical time? Only a thought although, not a fan of this method, and I feel it gained’t be almost as related given the character of future deliberate UI updates…
  • This one’s simply fluff, however I can see suggestions SFX and an non-obligatory very quick animation for the transition between zoom and commonplace view, for individuals who wish to use each and do it in fashion 🙂

Plenty of non-obligatory options on the market, it seems, although precisely what number of of them are literally helpful, and extra importantly can truly be applied in a means that brings out that usefulness, stays to be seen.

Anyway, these are just a few basic notes for now, and I haven’t accomplished any actual taking part in with this function lively, however later as soon as it’s truly constructed and never hacked collectively I’ll undoubtedly be attempting out some runs to see what about this setup irks me and if there’s something I can do about it.

Though a zoomed map this isn’t the sort of function I wish to use, I think about it could possibly be helpful to others, and look ahead to seeing the place growth takes it. I’ve all the time cherished engaged on UI to start with 🙂

That is the second in a five-part journey via the method of placing all this collectively:

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles