且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C ++游戏,类设计和职责

更新时间:2023-02-02 21:31:51

对于全局类,我将使用单例,然后调用Game :: GetInstance (),它将返回一个指向全局类的指针。

As far as making a class global I would use a singleton, then just call Game::GetInstance() which would return a pointer to the global class.

对于粒子,我一直处理游戏的方式是创建一个管理所有对象的类。在我的游戏主循环中,我将调用类UpdateObjects函数,它将通过它存储的项目列表,并调用每个更新函数。与Render和Collision相同。

As far as the particles, the way I've always handled games was to make a class that manages all the objects. In my games main loop I would call that classes UpdateObjects function which would go through a list of items it has stored and call each of there Update functions. Same thing with Render and Collision.