added gravity and collision detection