Wednesday, November 14, 2007

JavaScript, how I loathe thee

Random complaint: state is the root of all evil. I'm trying to get all existing sprites to update their trajectories when the game property's changed, but the trajectory data is duplicated in so many places.

Of course, I knew this already (yay Haskell), but there seems to be inherent state to this problem that can't be programmed away. For example, bounce/gravity can distort a sprite's trajectory so that its present course doesn't match the specified value; this happens to a single sprite, so we can't have them all share the GameProps' value. So we're stuck trying to reset trajectories of some fraction of existing sprites.