Added rudimentary support for tile collisions.

The collision detection code is not elegant right now, need major
reworks and refactoring. The unnecessary comments also mess up the code.