Added collision detection for entities
Merged and fixed the collision detection