Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

day four: letter ui, scaling the ui, displaying collected letters and disabling input

Date: 06.06.2025

Session Duration: 16:00 - 18:00

Progress

  1. Letter UI I list collected letters as UI elements on the top left of my screen. Later on, I will use their indices for player to re-read them. I also made a simple UI for the letter that displays the content and frames it with the color of the mood. I wrote very basic code, so there is a lot of duplication for the paddings.

When the player collects a letter, it is set as the active letter. For this, I added a new state to the player: PlayerStateReadingLetter. While in this state, the ui draws the letter

PlayerState :: union #no_nil {
	PlayerStateNormal,
	PlayerStateJumping,
	PlayerStateSmashing,
	PlayerStateDashing,
	PlayerStateReadingLetter,
}

PlayerStateReadingLetter :: struct {
	active_letter: Entity_Handle,
}
  1. Disabling Input I disabled all input except for Enter while reading letter. I did this very brutally for now
player := hm.get(&g_mem.entities, g_mem.player)
	player_data, _ := player.data.(Player_Data)
	if _, ok := player_data.state.(PlayerStateReadingLetter); ok {
		input = {
			enter = input.enter,
		}
	}
  1. Scaling the UI I had to do quite a bit of UI programming. The UI had to be scaled for the user's screen size, and things got messy in the beginning. But I figured it out.

Notes

  • I really don't think this code is going to scale. Getting the player entity takes too much effort every time because I am just using the bare-bones handle map functions. I should write a function to get it easily.
  • I might need a simple system for layouts, paddings, margins, and alignment.

Next Steps

  • Mood-based abilities (Still need to implement Inspired and Sad mood abilities. I think I'll do Sad the latest because it requires me to implement disabling collision temporarily)
  • One way platforms
  • A second level that has one way platforms, and an animated enemy
  • Level transitions