Game Development Reference
In-Depth Information
We set the crosshair to be in the center of the trace by taking its screen position and
subtracting half of the crosshair size. This allows it to use the center of the crosshair,
otherwise we'd be using the top-left corner of the crosshair as our center point.
DrawTile takes our texture, AltHudTexture , and uses that as our crosshair
image. For now it's just an image of a wrench.
7.
Don't forget to add our CheckCrossHairOnFriendly() function to DrawHUD
either. The function should now look like the following code snippet:
/*****************************************************************
* Draws the HUD
*****************************************************************/
function DrawHUD()
{
...
CheckCrosshairOnFriendly();
...
}
We'll make the necessary changes in our next recipe so that the color adjusts over
allies, but let's add the function now, which also stores the current info for our
crosshair in this recipe.
8.
Compile the project and take a look! We now have a crosshair that follows our
weapon's trace! We still have that other crosshair drawn in the center of the screen,
but that can obviously be removed by commenting out DrawWeaponCrosshair()
from DrawHUD() .
 
Search Nedrilad ::




Custom Search