rubber-duck.blog — nvim
← blog

Box Rendering System

Before I even got started on the rendering system, I had a bigger fish to fry. A game that’s entirely keyboard-based did not have keyboard shortcuts in the menu screens. It did have arrow key controls, but it did not have key binds for play or exit. This was an easy fix — I simply mapped the number pressed to the button order. I also added Vim controls because who doesn’t love Vim (j for down, k for up).

Now back to the main topic at hand.

I started working on the new rendering system that I mentioned in the previous post.

The code was shockingly simple and only took me about an hour with debugging and several syntax checks (still not very used to Lua). The main idea was:

  • Map a character to an image
  • Use the characters to describe the image

The most time-consuming part of this whole process would be loading the image into Love. The solution for this was to create a cache for each image so it is loaded once and then reused every other time.

The rendering is done through simply iterating over the ASCII characters and rendering the image associated with them.

There was some light maths involved to calculate the square size and centring the image properly.

This new system also allows for dynamic backgrounds as I can change the ASCII at runtime and change individual tiles. A use case for this could be showing a closed door when a room has not been visited and opening it after it has been.

This system is 99% done. All it needs now is to assign textures and create room sets, which is still a tedious task but much easier now.

// related project
Terminal Mysteryactive
⎇ mayaanhafeez/TerminalMystery3 other posts about this project
Press : for a command, Ctrl+P to search,Ctrl+T to cycle theme, Ctrl+S to cycle style