Updated game loop with dependency injection