Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Akumayo on Sat 06/05/2006 05:12:31

Title: RawDrawUnfilledCircle (SOLVED)
Post by: Akumayo on Sat 06/05/2006 05:12:31
Is it possible, even with a workaround, to make AGS draw an unfilled circle, rather than the filled ones it draws currently.Ã,  The ability of the engine to do this is crucial to the user-end of my game...

-Thanks in advance, Akumayo
Title: Re: RawDrawUnfilledCircle?
Post by: Kweepa on Sat 06/05/2006 07:36:40
Of course, using the RawDrawLine function.

[EDIT] Heh, I started writing it with radians, but then changed it half way because I was sure CJ had "dumbed down" the functions to take degrees :) Silly me. Code erased because Wretched's is obviously better (and working!).
Title: Re: RawDrawUnfilledCircle?
Post by: Wretched on Sat 06/05/2006 09:33:23
 Maths.Sin() and cos() use radians. Also you could get a duplicate arc due to floating point precision with < 360.0


function RawDrawUnfilledCircle(int x, int y, int radius)
{
Ã,  float farcs;
Ã, 
Ã,  float fradius=IntToFloat(radius);
Ã,  float t0;
Ã,  float t1;

Ã,  farcs=2.0*Maths.Pi*fradius/10.0; //Try to keep big circles smooth
Ã,  farcs=IntToFloat(FloatToInt(farcs));
Ã,  if (farcs<18.0)
Ã,  {
Ã,  Ã,  Ã, farcs=18.0;
Ã,  }
Ã, 
Ã, 
Ã,  float a=0.0;
Ã,  while (a<farcs)
Ã,  {
Ã,  Ã,  t0=(a)*Maths.Pi*2.0/farcs;
Ã,  Ã,  t1=(a+1.0)*Maths.Pi*2.0/farcs;
Ã,  Ã, 
Ã,  Ã,  RawDrawLine(x+FloatToInt(fradius*Maths.Cos(t0)),
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  y+FloatToInt(fradius*Maths.Sin(t0)),
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  x+FloatToInt(fradius*Maths.Cos(t1)),
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  y+FloatToInt(fradius*Maths.Sin(t1)) );
Ã,  Ã,  a=a+1.0;
Ã,  }

}

Title: Re: RawDrawUnfilledCircle?
Post by: Akumayo on Sat 06/05/2006 16:19:48
Wow Wretched!  Thanks alot.  Now I know how to go about scripting something like this!