viernes, 10 de mayo de 2013

Physics are very much f***ing hard

Implementing physics has been a pain in the ass.

First, you must learn to use a new library for each project (Box2D in this case, Bullet in my previous/main project), and then you must adjust your frame of reference to the objects on the graphical representation side.

Turns out, it was easier to leave out all my preconceived notions and follow development naively, and it has became easier to implement thanks to this new view.

Also, this week i refactored a lot of old code, for example, previously all my graphical representation was manually rendered like this:

But after refactoring, it became a three class system, with a very much needed separation of concerns:

It is a nice change of classes, and although it generated more boilerplate, it derives on good, readable code, which is a must for a project that will probably take a whole year.

What do you think? what is the most common problem to solve when refactoring?

1 comentario:

  1. Box2D is not that hard. It encapsulates physics behavior. As you say, if you start with preconceived ideas, you will have a hard time understanding how it works. Once you learn the ropes, you will have a much easier time. The best skill with Box2D is to have an intuition of the best numbers to put as parameters.