added int delta argument to the applyGravity method