Drawing a Threat map

Drawing a Threat map

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Fengshui
Posts: 9
Joined: 13 Mar 2008, 21:40

Drawing a Threat map

Post by Fengshui »

Hi I was wondering what the best (simplest) way would be to draw the threat map my AI is using onto the actual game map. I noticed in the aiCallback there are some draw line etc. funtions should I use these to draw my threat map? I was thinking of either drawing the threat grid and having it be different color and darker or lighter based on the influence in the grid cell. Or/also drawing the threat cirlce generated by individual units. If anyone has any advice on how to do either that would be great!
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Drawing a Threat map

Post by Kloot »

To draw your grid cells the CreateLineFigure() callback is
probably the most useful (just have it draw lines equal in
width to the cells themselves), for coloring them by their
threat-values you could call SetFigureColor(). Circles are
trickier though, you'll have to combine a bunch of splines
if you really need them (or let your AI run some Lua draw
callins). ;)
Fengshui
Posts: 9
Joined: 13 Mar 2008, 21:40

Re: Drawing a Threat map

Post by Fengshui »

Thanks for the adivce, I have a nice little threat map now. The one problem I am having is I don't understand how the setFigureColor() parameters work, they are RGBA and I assume they are from 0-255 but when I try to set them to values in this range they behave strangely (darker when I would expect them to be lighter). Could someone please explain what mistake I am making here I am too tired to figure it out :(
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: Drawing a Threat map

Post by SinbadEV »

Not sure but quite a few of the colour values use 0.0 to 1.0 as their range... at least give it a try.
Fengshui
Posts: 9
Joined: 13 Mar 2008, 21:40

Re: Drawing a Threat map

Post by Fengshui »

Yeah that seems to be the problem, I was confused because I was feeding it numbers like say 100 then 100.5 so it seemed to work but then when it hit 101 it restarted the scale. Keeping the values between 0 and one fixed the weirdness. thanks!
Post Reply

Return to “Engine”