Michael Pidde => { Programmer(); }

Smooth Move

Getting back to Boreal Darkness after a time away, I took some time to debug jerky player movement that has been plaguing me since the start of the project. When you're working on a project and run into unexpected behavior that you can't readily figure out, it can be tempting to move onto more exciting parts of the code and continue feeling the motivation of forward momentum. The problem might not be critical enough to fix right now; enter technical debt. It's good enough for now, so we're paying for it on credit that'll have to be paid back later. Well, I paid it back tonight, finally.

As often happens, the bug was really stupid. Easily overlooked. I had to extract a function call to the player move function from the SDL key event code and move it into the game loop update function. That way it tries animate the player continually, not just when a key is pressed. The problem was a bit more nuanced than that, but I'll spare everyone the technical blood and guts.

Here's proof positive of the fix: