Another slow week. Most of my work went into moving to the new object model discussed previously – splitting bits of data and logic out into the Level and RuntimeLevel classes, fixing bugs as they cropped up, and so on. One thing I had to do in order for that to work that I hadn’t anticipated was change my object model so that every object in a given level had a unique name. Previously names were optional, but in the new object model it didn’t really make sense for objects to not have a name, or share the same name. After resolving that, some other issues cropped up – for example, bounding boxes weren’t updating correctly for some moving objects like doors and moving platforms, which meant that in some cases an entity could slip through an obstruction.

Once the issues resulting from the switch were resolved, I started making some improvements to my moving platform code so it was easier to put to work. The first problem was that the use of cubic interpolation caused platforms to move at an inconsistent speed – slowing down as they approached waypoints on their path, and accelerating as they grew more distant. I spent a little time experimenting with various approaches to solving this, and ended up settling with a simple hack, where I do a binary search of the curve to find the next point along the curve that is a given distance away from the current one. While not mathematically pure, it was easy to build and solves the problem, and after implementing it I was surprised by how much better the motion of the platforms looked as a result of them moving consistently.

After this I spent some time improving the editor’s support for dealing with objects that move, making it possible to see a simple visualization of their path so you can get an idea of possible collisions and where it’s going to move.