andymaul123 / pca-engine

Learning htmx and servers
0 stars 0 forks source link

Feature: Player Context #2

Closed andymaul123 closed 6 months ago

andymaul123 commented 6 months ago

Description

A hallmark of the Point & Click genre is the ability for a player to choose an 'action' type to interact with the world. Prior to this feature, the game only had one type of interaction. This pull request adds 'Player Context'.

The Context Bar

A set of three buttons is affixed to the bottom row of the screen (via Radio Buttons). This is the control mechanism for the player to change their interaction context. The buttons are styled using the checked property. When a button is pressed, a request is made to the server that returns a new scene.

Interaction Overlay

When context is changed, the scene is re-rendered with only the matching interactables available. This initially caused any Scene Starting items to re-fire, so those were extended with additional logic to prevent it.

Contexts

To start there are three available:

Any interactable in the scene is defined separately, and named with a trailing underscore and the context, e.g. npc1_look and npc1_talk. Additional contexts can be added in the future without needing to update existing data.