Added collision detection and gravity