SA-MP Forums Archive
Can't create a perfect circle with beach balls. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Can't create a perfect circle with beach balls. (/showthread.php?tid=456092)



Can't create a perfect circle with beach balls. - sleepysnowflake - 04.08.2013

so I have this problem where I can't seem to be able to make a circle. instead of that it creates something .... similar

pics here there are 4 pictures


code:

pawn Код:
if (strcmp("/circle", cmdtext, true, 10) == 0)
    {
        // should create a perfect circle; radius 4; center of circle = (0,0);
        new Float:y1, Float:y2, pPos[3];
        new Float:test=-4.0;

        while(test<5) {


            y1 = -(floatsqroot(16-floatpower(test,2)));
            CreateDynamicObject(1598,test, y1, 10, 0, 0, 0,-1,-1,-1, 10000);
            y2 = (floatsqroot(16-floatpower(test,2)));
            CreateDynamicObject(1598,test, y2, 10, 0, 0, 0,-1,-1,-1, 10000);
            printf("i=%f\ty=%f\ty2=%f",test, y1, y2);
            test = test + 0.5;
        }
        return 1;
    }



Re: Can't create a perfect circle with beach balls. - Vince - 04.08.2013

You need the trigonometric functions, i.e. sine and cosine.

pawn Код:
new
    Float:radius = 4.0;  
    Float:angle;

while(angle < 360.0)
{
    new Float:x = radius * floatsin(angle, degrees);
    new Float:y = radius * floatcos(angle, degrees);

    CreateDynamicObject(1598, x, y, 10.0, 0.0, 0.0, 0.0);

    angle += 0.5;
}
I'm not too good with trig stuff, but something along those lines ought to work.


Re: Can't create a perfect circle with beach balls. - sleepysnowflake - 04.08.2013

okay but why can't I do it the way I tried to do it? it works, somewhat. should I made their spawning even closer to each other? could that be the solution?