UI and Options


Finally implemented a basic UI with persistent game options. This took longer than expected as I went down a rabbit-hole of starting to wire up Nuklear before realising that I could simply create a new Selectable component to complement the existing Text component.

typedef struct Selectable
{
  bool focused;
  bool toggle;
  bool value;
  Rectangle region;
  void (*callback)(GameOptions *options, bool value);
} Selectable;

The system that renders the Text component updates the region of the Selectable component (if it exists), and this is used to detect whether the cursor is hovering over the text. A new UI system simply iterates over Selectable components to decide which is active, and the relevant callback is triggered when a selection is made.

I also created a simple Options component, which is a singleton (similar to Input), and which is passed to relevant systems (for example, updating the player requires Options to determine whether the y-axis should be inverted or not). This component is serialised to allow it to persist between game sessions.

Altogether not much fun, but it is functional, and didn’t take too much time (thanks to Flecs). Now on to polishing the controls and fixing a few niggly bugs before moving on to greater things!

Files

blattix-mac-alpha.zip 28 MB
Version 0.3.1-alpha+cf6a644 May 27, 2021
blattix-linux-alpha.zip 28 MB
Version 0.3.1-alpha+1305a5d May 27, 2021
blattix-win-alpha.zip 27 MB
Version 0.3.1-alpha+cf6a644 May 27, 2021

Get BLaTTiX

Buy Now$1.99 USD or more

Leave a comment

Log in with itch.io to leave a comment.