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)

Monday, August 24, 2015

Life of the Samurai - 2. The Battles


The Concept

We will get started with the Battle Mode. Here is an in-game screenshot to give you a feeling for the kind of battles we are talking about. Just keep in mind that the sprites used are only temporary and will be replaced eventually:


As seen in the screenshot, the battles are 2D with a top-down view. 

The player controls the units beginning on the bottom of the battlefield, which can be one of the following classes:

  • Sword Infantry
  • Spear Infantry
  • Samurai with bows
  • Cavalry 

The unit classes have their strength and weaknesses and when used correctly, allow for a rock-scissor-paper take of the battle, where spears easily defeat cavalry, cavalry easily destroys archers and archers are well suited against infantry of all kinds. Sword samurais are well-rounded in most perspectives.

Beyond the attack and defense power, there is stong differentiation in the movement possibilities for the different units:

  • Cavalry is the quickest unit and the only unit capable to quickly cross streams and high grass or wheat fields. Infantry units have more difficulties with the terrain. A disadvantage of cavalry is their slow rotation speed.
  • Archers are the quickest unit on foot and will try to back away when engaged in a melee battle of any kind, as they are the weakest in terms of armor.
  • Spearmen are quite slow, both when advancing and turning around, however their armor makes them very resistent to engagements up close. Just don't put them face to face with the nimble archers.
  • Here, swordsmen are once again the best all-rounders, and get along relatively well in any situation and against any enemy.