Development diary week 09 - GideonPARANOID/olandroid GitHub Wiki

This last week has been a slow one, & I've only really worked on one feature (besides the refactoring) - the alternative animation style I talked about a little bit in the last post.

The animation method is best described as a 'flying wing' - basically a small section of the total flight is drawn, & this section moves along the path of the flight, with the flight disappearing behind it.

Now, this took a while to get my head around - & it's still kind of buggy. This animation code is in all of the different parts which make up a flight - the flight, manoeuvres & components. In the components, a method for scaling the back of components needed to be written, then in the manoeuvres there needed to be a method for going through from the beginning to the end & in the flight, there needed to be support for having part of the wing in two manoeuvre when the wing is between the two. The simplest parts to write were the components & flight flying wing bits, but the manoeuvres section was tricky due to components being different lengths & the animation function taking a value between 0 & 1 (the only logical way to implement it).

In pseudocode:

get progress through the manoeuvre relative to the total length of all components

for every component until the cumulative length of components is more than the progress through the manoeuvre:
    hide component

if the current component's length is less than the length of the wing:
    animate the current component from start to end within the current component

else:
    animate the back of the wing in the current flight
    
    while wing length is more than zero & the wing will fit in the current component:
        fill the full component

    if still in the manoeuvre
        animate the front of the wing to the degree of wing left

There's a few edge cases that still need ironing out, but that's basically it.

Most of the refactoring has been to do with strengthening the interface. Previously, the code wasn't using the features of Java as well as it could be - using public static ints as effectively enums - so I improved & disambiguated things, using enums. This improves encapsulation loads & prevents cases where any value of an integer could be passed when there were actually a limited set of options. Things are much clearer now!

This week's demo.