Refactored movement into separated functions.

checkHorizontalCollision now manages border collisions.