Managing Scenes

I’m trying to be very cautious about how the groundwork for the engine is established; being lazy at the beginning will lead to big headaches down the road once content starts pouring in. As an example, I had to spend several hours reworking every item class definition when I changed the class spec for Item, because every single change had to be performed individually on all ~50 current item files.

One of the larger mechanical details I’ve been running in circles on is managing Scenes. Being the primary interactive element in the game, it’s fairly important to make sure that data for Scenes is structured in a way that is

  • easy to work with
  • tracks all the relevant data for local flags, objects, states, etc
  • able to store and recall said data from save without bloating the filesize
  • reusable and modular to accommodate
    • static events
    • random events
    • timed events (from Event objects or Time of Day)

I had originally played with a singular Scene class, but they quickly became overburdened with functions for every variation of NPC dialogs, object interactions, events, etc, and were not very intuitive for logically separating flags and data for all these conditions. After a few weeks of tinkering, I think I’ve settled on a solution that separates the ingredients for scenes into Location and Topic classes, using standard hooks for each class family to make them accessible. Take a look at the following outline:

Diag_TopicLocation

 

Each large square represents an individual class which handles it’s own variations and permutations. The dark function blocks are the primary accessors defined in the base class definition for those types.

Classes of type Location should (ideally) contain no scene text (meaning output to the game screen using game.write()); they manage information like what other Locations are accessible from that area, which Actors and Objects are present, what environmental states are active (stormy vs clear, interior vs exterior, etc), and what Topics are available.

Topics manage the flow of storytelling and dialog, containing all the parsing for Actor variables (names, genders, descriptions; things that vary from Actor to Actor) into the scene text, and building the actions list.

Leave a Reply

Your email address will not be published. Required fields are marked *