How do I draw a radar triangle?
BlitzMax Forums/BlitzMax Beginners Area/How do I draw a radar triangle?
| ||
How do I draw a radar triangle of various sizes? Take a look at this graphic: If you read the text, you may substitute the word "camera" for "radar". Basically what I'm trying to do is create radar triangles of different sizes (eg. the angle of the cone [eg. width of the radar] and distance [eg. how long it is]). I'd also like to draw that fancy curve at the end of the radar triangle if possible... (kind of like a pie slice of a circle, etc) Thanks for any help! |
| ||
Use an image, rotate and scale it. Simplest for collision if you wanted to have that the round part will otherwise not end that funny. alternatively you can (must) use a texture polygon routine |
| ||
Thanks for the reply... How would I adjust the angle of the radar? (eg. suppose the radar was 170 degrees wide) |
| ||
set the image handle to where the focal point of the radar is, then use setrotation to set the angle of the radar. use: setimagehandle(image:timage,x#,y#) setrotation(angle#) [edited] I posted it wrong it's not sethandle - corrected |
| ||
Or you can draw the pie like I did in the "How to draw something like a pie chart" post. Here is some example code that you can change to draw your radar thing: Good luck! |
| ||
Strict Graphics 1280,800,16,80 Local SweepStart:Float = 180.0 'Degrees Clockwise Local SweepEnd:Float = 360.0 Local SweepRate:Float = .75; Local SweepDistance:Float = 375 Local SweepOriginX:Float = GraphicsWidth() / 2 Local SweepOriginY:Float = GraphicsHeight() / 2 Local SweepAngle:Float = SweepStart Type EndPoint Global EPList:TList = New TList Field X:Float, Y:Float Field FadeRate:Float = 250000 Field Ticks:Int = MilliSecs() + FadeRate Field Alive:Int = True Field r:Float = 255 Method Render() Local Diff:Float = Float(Abs(MilliSecs() - Ticks)) / FadeRate r :* Diff SetColor 0, r, 0 Plot X, Y If MilliSecs() > Ticks Then Alive = False End Method Function RenderAll() For Local ep:EndPoint = EachIn EndPoint.EPList ep.Render() If Not ep.Alive Then EndPoint.EPList.Remove(ep) Next End Function Function Create:EndPoint(XPos:Float, YPos:Float) Local ep:EndPoint = New EndPoint ep.X = XPos; ep.Y = YPos Return ep End Function End Type While Not KeyHit(KEY_ESCAPE) Cls Local epX:Float = SweepOriginX + Sin(SweepAngle) * SweepDistance Local epY:Float = SweepOriginY - Cos(SweepAngle) * SweepDistance Local epX2:Float = SweepOriginX + Sin(SweepAngle) * SweepDistance / 2 Local epY2:Float = SweepOriginY - Cos(SweepAngle) * SweepDistance / 2 Local ep1:EndPoint = EndPoint.Create(epX, epY) Local ep2:EndPoint = EndPoint.Create(epX2, epY2) 'ep2.FadeRate = 250000 * .75 SetColor 0,255,0 DrawLine SweepOriginX, SweepOriginY, epX, epY EndPoint.EPList.AddLast(ep1) EndPoint.EPList.AddLast(ep2) SweepAngle :+ SweepRate 'If SweepAngle > SweepEnd Or SweepAngle < SweepStart Then SweepRate = -SweepRate EndPoint.RenderAll() Flip Wend |