Game Development Reference
In-Depth Information
Figure 62 - Mapping the 3D coordinate space into 2D.
We will begin by defining a transformation matrix R(π/2) that we will use to rotate the
damage direction vectors wereceive aboutthe x axisby90degrees, thiswill giveusanew
direction vector in the screen coordinate space.
We can use this new direction vector to calculate the angle of rotation that represents the
angle from which the damage was inflicted. The x,y axes give us the sides of a right tri-
angle, we can then use trigonometric functions to calculate the angle of rotation.
This will give us the angle by which we need to rotate our sprite, however, depending on
how the sprite's texture is provided, the calculation may need to be adjusted, in this ex-
ample we will use the following sprite:
Figure 63 - Damage indicator texture.
Search WWH ::




Custom Search