Internets down, physics refinement

My internets have been down for the past 24 hours, due apparently to a burst water main flooding the exchange. Below is my diary entry for last night.

Today's progress was poor, which is a serious setback when I'm estimating having 2 programming days left. I spent too long today tweaking the character physics. The physics are very good now, and the upside is that the terrain feels great to run and jump on - you get some nice speed kicks when you land on a downward slope.

The fight to get friction working came down to numerical accuracy. Friction acts in the opposite direction to the player's velocity along the slope, if the velocity is not zero. But as you come to a stop, this velocity becomes small, but due to floating point errors, not actually zero. Normalizing this vector gives completely the wrong results - it actually starts the object moving again.

The moral of this story is that in a 2D vector class, __nonzero__ should read

def __nonzero__(self):
        return abs(self.x) > ERROR_TOLERANCE or abs(self.y) > ERROR_TOLERANCE

Now I'm up against it though. I have two days in which to take what is basically a platformer engine - though I am fairly satisfied with it - and make a game with it. I have plenty of innovative ideas to add but I value production and fun much more highly.

In today's screenshot I've added some trails to the player to illustrate the physics in action - notice how the player's velocity changes as a function of the terrain.