Michael Cook’s Place

Bits of Genius in a Sea of Mediocrity

Michael Cook’s Place Random Header Image

Gravitoids Gravity Error

January 9th, 2009 · No Comments

I am continuing to work on Gravitoids. While working a little while ago I found one of the problems that’s been in the code. When the force of gravity on an object was set, it was actually being done as an addition. So instead of the correct way of doing things (pseudo code):

object.forceOfGravity = calculatedForceOfGravity

I was doing this:

object.forceOfGravity += calculatedForceOfGravity

This has made a noticeable difference, although I still suspect something odd is going on in a different part of the code. I’ve also added methods to be able to turn off the influence of either gravity or thrust during testing so I can see what’s going on easily in the middle of a simulation. All you have to do is press the keys to enable/disable the (E)ffect of gravity or (F)orce of thrust.

Tags: Programming