Implement the main physics loop