Game Development Reference
In-Depth Information
<var name="WeakHitpoints" UnitType="HitPoints" value= 5 0 />
<var name="MediumHitpoints" UnitType="HitPoints" value= 1 0 0 />
<var name="StrongHitpoints" UnitType="HitPoints" value= 1 5 0 />
<var name="MegaHitpoints" UnitType="HitPoints" value= 1000 />
<object name="Goblin" HitPoints="WeakHitpoints" />
<object name="Goblin Knight" HitPoints="MediumHitpoints"
/>
<object name="Goblin King" HitPoints="StrongHitpoints"
/>
<object name="Kobold" HitPoints="WeakHitpoints" />
<object name="Kobold King" HitPoints="StrongHitpoints"
/>
<object name="Peasant" HitPoints="HumanHitpoints"
/>
<object name="Knight" HitPoints="StrongHitpoints"
/>
<object name="King" HitPoints="WeakHitpoints" />
<object name="Dragon" HitPoints="MegaHitpoints" />
<object name="Lich" HitPoints="MegaHitpoints"
/>
Much like data inheritance, by using semantic information instead of hard-coded
values, it is much easier to understand the meaning of the data instead of seeing
only the values. Now, if it is determined that the entities are too easy or hard, only
a small number of constants need to be tweaked. These constants trickle down into
each associated class.
But it is important to keep in mind that just because two values are the
same, they do not have to use the same constant. Above, the Peasant and the
Goblin Knight may have the same number of hit points, but by using two dif-
ferent values we will not accidentally change one value when we are tweaking
another.
14.3.2 Implementation
In the raw data, data constants can be treated like any other object in an object
database. Existing tools do not need to handle these constants in any special
way—they are just small objects. Then, during the build, a tool can process all of
the objects. Whenever an object refers to a constant, the value of that constant
can be copied into that object directly. This copy step would be completely tool
only.
Additionally, while embedding the constant values into the actual objects where
they are used, additional semantic verification can be done. Constants do not
have to be of type integer ; instead these values can be marked by what the
data represent. Constants can have their actual units attached to them. Instead
of marking a field as an integer or float , a field would be marked as distance
or temperature. These units can prevent designers from using a constant that
may currently have the value they expect, but conceptually may have a different
meaning. In the future, data can be refactored without inadvertently modifying
unrelated information.
Search WWH ::




Custom Search