Refactor ball swimmer scripts

My goal here was to refactor the existing ball and swimmer scripts to put code into logical functions that can be called in different places if needbe.