This is a code snippet from IronStrike, which draws the units on my radar...
Very simple, isn't it?
Code:
for i := 0 to ISUnits.Count-1 do
begin
ISUnit := ISUnits[i];
if ISUnit^.Life > 0 then
if Distance(Player.PosX, Player.PosY, ISUnit^.PosX, ISUnit^.PosY) < 450 then
begin
if ISUnit^.Faction = Player.Faction then
RectColor := $4400FF00
else
RectColor := $440000FF;
MyCanvas.FillRect(Bounds((RadarMiddleX + trunc(ISUnit^.PosX - Player.PosX) div 10),
RadarMiddleY - (trunc(ISUnit^.PosY - Player.PosY) div 10),
3,3), RectColor, fxAdd);
end;
end;
Just cycle through all your rockets, decide which color you want to have the dots on the radar (in your case kind of missiles) and draw them.
In my case I scan all units (friends and foes) which are within the radius of 450 gameunits from players position.
Then I calculate the position (Unit.PosX - Player.PosX, same with PosY) and add the value to the middle of my radar. The values are divided by 10 to make the 90 pixel big radar show 900 game units...
I think you can use this nearly the same way.
Hope this helps to get a radar soon
Greetings,
Dirk
PS: I am at work right now and can't test your new upload. I will do it when I am home again.
Bookmarks