Game Development Reference
In-Depth Information
blip . position = playerToEnemy
blip . position /= range
blip . position *= radius
// Add blip to list of blips
blips .Add( blip )
end
loop
end
function Draw( float deltaTime )
// Draw radarImage
...
foreach RadarBlip r in blips
// Draw r at position + blip.position,
since the blip
// contains the offset from the radar cen-
ter.
...
loop
end
end
This radar could be improved in a few different ways. First of all, we may want to
have the radar not only show enemies, but allies as well. In this case, we could just
change the code so that it loops through both enemies and allies, setting the col-
or of each RadarBlip as appropriate. Another common improvement for games
that have a sense of verticality is to show different blips depending on whether the
enemy is above, below, or on roughly the same level as the player. In order to sup-
port this, we can compare the height value of the player to the height value of the
enemy that's on the radar, and use that to determine which blip to show.
A further modification might be to only show blips for enemies that have fired
their weapons recently, as in Call of Duty . In order to support this, every time an
enemy fires, it might have a flag temporarily set that denotes when it is visible on
the radar. So when iterating through the enemies for potential blips, we can also
check whether or not the flag is set. If the flag isn't set, the enemy is ignored for
the purposes of the radar.
Search WWH ::




Custom Search