Can't create a perfect circle with beach balls.
#1

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;
    }
Reply
#2

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.
Reply
#3

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)