Thursday, August 27, 2015

Some Technical Mambo Jambo

The engine used to build the game works on an eventsheet-layout-layers principle. If this sounds boring to you, then you can go ahead and skip the "Events List" section, it's mostly about that. I won't be mad, I promise.

Events List
The specific arrangement of the metagame (e.g. the game which encompasses all other minigames like the duels and battles) - with different windows appearing and disappearing at flexible intervals depending on the internal on-goings - made it quite difficult to organize the code.

At first I tried creating separate layouts for each event, but the effort of doing so combined with the jungle of swaps that was going to happen between the different layouts made this option become very unattractive, very fast.

The second approach was to have one layout with multiple displayed layers, and swap the visibility of layers based on the current needs. However, the engine used had a problem with this approach, as it a) did not deactivate elements on invisible layers and b) could not wait for an event to finish before continuing to the next one (Waiting for Signals is only possible for actions inside events.)

The solution that proved most effective and which I am really happy with is this:
Every time an event occurs, be it the player going from A to B or a random "SamuraiAppearsOutOfNowhere" function firing, the certain event is being added to the end of a list (or to the beginning, if it shall precede all other events already in the list). Then, a certain layout is restarted for every element of that list, starting from the back, and dynamically building an individual page for each element, after which discarding that list element. By resetting the same layout each time, we don't have to wait for any events to start or finish, and we don't have to rely on layers visibility and their elements.

Also, this offers the nice possibility to write down a history of everything that has taken place. Sweet!


Finite State Machines
(coming soon)

Tilemapping
(coming soon)

Mathematical Concepts for Unit Positioning
(coming soon)

No comments:

Post a Comment