[SDL] "Perfect" circles
Mike Shal
marfey at gmail.com
Thu Nov 9 12:48:27 PST 2006
Though others have already answered your main question, you have a
small error that may cause other trouble:
On 11/9/06, xEsk PiV <xeskuu.sdl at gmail.com> wrote:
> float pre_cos[360];
> float pre_sin[360];
> bool is_pre_cos_sin_init = false;
>
> const float PI = 3.14159265358979323846;
>
> float RadToDeg(float rad) { return rad * 180 / PI; }
> float DegToRad(float deg) { return deg * PI / 180; }
>
> void init_pre_math()
> {
> for(int i = 0; i <= 360; i++)
> {
> pre_cos[i] = cos(DegToRad(i));
> pre_sin[i] = sin(DegToRad(i));
> }
Your arrays are size 360, but you're writing to index 360, which is
non-good :). You probably meant:
for(int i = 0; i < 360; i++)
(not <=)
-Mike
More information about the SDL
mailing list