Refactor check collision function and some global variables to game object