game loop and tick method