- Game Development Patterns and Best Practices
- John P. Doran Matt Casanova
- 221字
- 2021-07-02 23:43:48
The benefits of the monolithic game object
It is worth noting that even if you choose this approach, you can still have your core engines decoupled from the game object. When writing the graphics engine, for example, instead of passing in a game object as a parameter to a Draw function, we could pass in the members that the graphics engine needs:
void Graphics::SetTexture(int textureID);
void Graphics::SetTextureCoords(const float* coordArray);
void Graphics::Draw(const M5Mtx44& worldMtx);
vs
void Graphics::Draw(const Object& obj);
Another argument for creating objects like this is that we know exactly what is in our game object. Compared with other approaches, we never need to cast our object or search for properties within the object. These operations make the code more complicated and have a slight performance cost. By using a simple struct, we have direct access to the variables and the code is easier to understand.
The only time we might use this approach is if we know 100% that the number of object types won't be large, for example, if you are making a puzzle game and the only game objects are sheep and walls. Puzzle games are often very simple and use the same mechanics over and over. In this case, this is a good approach because it is easy and doesn't require any time building a complicated system.
- Advanced Quantitative Finance with C++
- Android應用程序開發與典型案例
- Mastering Adobe Captivate 2017(Fourth Edition)
- 算法零基礎一本通(Python版)
- 高效微控制器C語言編程
- Learning ArcGIS Pro 2
- AngularJS Web Application Development Blueprints
- 三維圖形化C++趣味編程
- PHP+MySQL網站開發技術項目式教程(第2版)
- Linux操作系統基礎案例教程
- 運用后端技術處理業務邏輯(藍橋杯軟件大賽培訓教材-Java方向)
- Android驅動開發權威指南
- jQuery技術內幕:深入解析jQuery架構設計與實現原理
- Python 3快速入門與實戰
- Node.js實戰:分布式系統中的后端服務開發