Logical gymnastics

No blog post yesterday since i didn’t have any noticeable success so it didn’t feel worth it to write one.

Today i finished the input system for the spells, the idea behind the system is fairly simple; check if the stick is in* one of 9 specified positions*, return that position’s assigned number and place it into an array of Integers*. Then compare the array with the arrays included in the spells available to the player*, if they match then the player casts the corresponding spell*.

Now, every asterisk represents a somewhat serious issue. First, I had thought the stick positions was two integers between -100 and 100(despite using floats for all functions including the values), today i realized that the numbers were actually floats between -1.0 and 1.0 which meant i had to re-enter the values in the dofferent positions which leads me to the second asterisk. First of all the sticks positions were not at maximum/minimum when in on of the “corners” of their movement range but rather at around the coordinates (70,70) which meant the corner nodes were all wrong, secondly i had forgotten that negative 80 is higher than negative 100 and should therefore be the maximum value, rather than the minimum. In the end i solved the issue and all values are now correct and tested.

Next off, those arrays needed to be added to the list of arrays, emptying the array over time when it gets larger than the longest possible combo is taken care of in the player’s update function, however because of the way stick inputs are read, the array should not have repeating numbers within it which game me most of my issues today.

The problem was that when getting the final element of the path array and comparing it to the number to be added became more problematic because when running the GET function with the LAST result as it’s argument in order to get the last element, it returned 0 when empty  which played hell with my booleans until i figured it out, eventually i found a solution shown in the picture. The trick was to make sure the number was only stopped from being added if the last value was equal to the new one AND the array wasn’t empty. input logic

The final two issues which i will dig into next time is comparing the arrays or possibly just segments of the array, i have one function but never properly tested it, and finally actually selecting the spell. This is kind of tricky since i have to edit the base struct for spells to include an array of numbers to represent the combination needed to perform the spell.

A lot of these things i have done in order without testing properly or making entierly sure they worked, i wonder if this is a good method of work. On one hand i can get a good overview of the requirements and can spot any major flaws easily before working my way to the end just to find out the final step can’t be done, making the entire process moot. But on the other hand some work may be wasted and the individual parts will be done slower. Perhaps this is a good thing to take up in out Post Mortem.