官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 武义县| 那坡县| 彭州市| 大同市| 满城县| 无极县| 基隆市| 安仁县| 寿光市| 和林格尔县| 海伦市| 陇西县| 铜鼓县| 那坡县| 中宁县| 新沂市| 鄂尔多斯市| 宣恩县| 务川| 神池县| 安岳县| 深泽县| 河北省| 翁牛特旗| 施甸县| 娱乐| 都兰县| 台东市| 页游| 博乐市| 本溪| 大庆市| 桓台县| 德清县| 中阳县| 镇宁| 始兴县| 揭阳市| 巫山县| 阿鲁科尔沁旗| 海林市|