Results 1 to 8 of 8

Thread: DrawCircle

  1. #1
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default DrawCircle

    After seeing a game (linerider) I quickly got addicted. The only problem I came across with it though was that it was very hard to make circles - thus DrawCircle was born. I do plan on adding a start and end angle, but since I'm using pythagorus instead of sine etc. it makes it hard since I'm lazy and it would involve some hard work .
    Now, to present it:
    SCAR Code:
    procedure DrawCircle(cx,cy,r: Integer);
    var
      x,y,y2,i: Integer;
      first: boolean;
    begin
      first:= true;
      for i:= 0 to 1 do
      begin
        for y:= -r to r do
        begin
          x:= Round(Sqrt(Sqr(r)-(Sqr(y))));
          if(first) then
          begin
            first:= false;
            Sleep(10);
            HoldMouse(cx+x,cy+y,True)
            Sleep(10);
          end;
          if(i=1) then
          begin
            x:=-x;
            y2:= -y
          end
          else
            y2:= y;
          MoveMouse(cx+x,cy+y2);
          Sleep(1);
        end;
      end;
      ReleaseMouse(cx+x,cy+y2,True);
    end;

    You just have to give it a place to start (cx and cy) then how big you want the circle to be (radius). A good example is to use it in paint - do be warned though that it goes slower as the circle gets bigger.
    Have fun
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  2. #2
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Really good i tried it in paint.


  3. #3
    Join Date
    Jul 2007
    Posts
    1,431
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You are really smartass
    This is better, though I made it, but don't understand sin,cos,tan
    SCAR Code:
    program New;

    var
      i,x,y,midx,midy,h,w : integer;
      angle, add, rad : extended;


    begin
      GetClientDimensions(w,h)
      midx := w / 2;
      midy := h / 2;
      rad := round((w + h) / 6);
      repeat
        angle := angle + 0.5;
        X := MidX + Round(rad * Cos(Radians(Angle - 90)));
        Y := MidY + Round(rad * Sin(Radians(Angle - 90)));
        wait(1);
        movemouse(x,y);
      until angle >= 360;
    end.
    [CENTER][SIZE="4"]Inactive[/SIZE]I forgot my password[/CENTER]

  4. #4
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    My one is smexier though
    Anyway, mine is more or less the same length (minus the holdmouse/releasemouse stuff and probably the semi-circle checker) and I know how it works.
    I'm guessing that your method makes a 'virtual triangle' outwards from the midpoint then gets the length of the across and up, only problem is I barely grasp regular trigonometry and scar's slightly different results confuse me. Ahwell, all is fair in love and scar.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  5. #5
    Join Date
    Oct 2006
    Location
    I'm also from Michigan!
    Posts
    563
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    ha! I did that once! It was pointless until beta2 introduced speed lines and you can make him go around in a circle forever. I used basically what negaal had only finished with holdmouse n stuff sry mix

    now for linerider gloating...

    BETA video

    BETA 2



    also, gratz useful poster cup!

  6. #6
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    procedure Circle(MidX,MidY,rad,sAngle,eAngle: Integer; accuracy,xOffset,yOffset: Extended);
    // Extra credit love to n3ss3s for the heart of the script (as posted by Negaal)
    var
      x,y,dloop,eloop: Integer;
      angle: Extended;
    begin
      angle := sAngle;
      X := MidX + Round(xOffset * (rad * Cos(Radians(angle -90))));
      Y := MidY + Round(yOffset * (rad * Sin(Radians(angle -90))));
      HoldMouse(x,y,True);
      Sleep(500);
      if(sAngle > eAngle) then
        eloop := Round((sAngle - eAngle) * (1/accuracy))
      else
        eloop := Round((eAngle - sAngle) * (1/accuracy));
      repeat
        if(sAngle < eAngle) then
          angle := angle + accuracy
        else
          angle := angle - accuracy;
        Inc(dloop);
        X := MidX + Round(xOffset * (rad * Cos(Radians(angle -90))));
        Y := MidY + Round(yOffset * (rad * Sin(Radians(angle -90))));
        wait(5);
        movemouse(x,y);
      until (dloop >= eloop);
      ReleaseMouse(x,y,True);
    end;

    Adapted from n3sses trigonometry tutorial for pure linerider pwnage
    It includes a start angle, end angle, accuracy (higher = faster, generally 1 or under), and an x and y offset (changes the shape of it, with xmod making the widest point xmod*radius and same with ymod).
    Mine even supports circles going in opposite direction and angle starting bigger than 360 (e.g. from 180 to 450 to go from the bottom to the right but clockwise)

    Edit: Thanks for the thanks and those are some awesome videos - I never seem to get past making a few curves... I really do need to get some follow through with something i do ><
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  7. #7
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    I haven't tested that function in the above post, but you do understand that if offset was 2, it doubles the radius, if its 3, it triples, etc, like what's the meaning of it?

  8. #8
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    That's pretty much it, all I wanted it to do was to alter the shape of the circle to make it look cooler. Also noticed that no matter what the start/end angle is, it'll always come up as the same shape when using the Offset's. I only used Offset because it was first thing that came to mind when making it, but using xMod and yMod would have probably made it clearer - ahwell.
    Edit: There are the 2 offsets so it can make the widest x point twice (to whatever it's set to) the radius, but the y offset can change aswell - e.g. xOffset of 2 and yOffset of 1 means the that circle is distorted to twice the radius when y is equal to MidY but the highest point is still equal to the radius.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •