Results 1 to 4 of 4

Thread: Need some quick Help with a TPA...

  1. #1
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Need some quick Help with a TPA...

    Alright, I got this script I'm working on (tut island runner, I plan to release within this following week), but I need a little TPA function which I just can't seem to find...
    What I am looking for is a function to check if a certain point (or TPoint) exists in the array. So for example if I would have the Point (45,36) and the TPA with the anme of "P", it is supposed to check if that certain point is included in the array...
    Thanks a lot
    -Pure1993
    There is nothing right in my left brain and there is nothing left in my right brain.

  2. #2
    Join Date
    May 2007
    Location
    Netherlands, Amersfoort
    Posts
    2,701
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    IDK if this works, test it

    SCAR Code:
    Function IsPointInArray(Point: TPoint; Array: TPointArray): Boolean;
    Var // by MasterKill
      MK: Integer;
    Begin
      For MK := 0 To High(Array) Do
      If (Point = Array[MK]) Then
      Begin
        Result := True;
        Exit;
      End;
    End;

  3. #3
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for the quick reply, I'll try it out right away.

    *cough* you don't capitalize the bolded words in the official standards *cough* (or has that changeg? )

    Edit: I wasn't able to test it yet (too busy expanding my script ), but I did an error check, and gotten ridd of the few things (just to be sure I changed "array" to "DaArray"), and also SCAR doesn't seem to be able to check an entire TPoint, so I made it check the x value and then the y value, so it looks like this:

    SCAR Code:
    function IsPointInArray(Point: TPoint; DaArray: TPointArray): Boolean;
    var // by MasterKill
      MK: Integer;
    begin
      for MK := 0 to High(DaArray) do
      begin
        if (Point.x = DaArray[MK].x) and (Point.y = DaArray[MK].y) then
        begin
          Result := True;
          Exit;
        end;
      end;
    end;

    Full creadits and thanks to you
    There is nothing right in my left brain and there is nothing left in my right brain.

  4. #4
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    I don't think his works because a type mismatch error (that I've been unable to solve) as well as his naming conventions. This one should work:

    SCAR Code:
    function IsPointInArray(ThePoint: TPoint; TheArray: TPointArray): Boolean;
    var
      i: Integer;
    begin
      for i := 0 to High(TheArray) do
        if (ThePoint.x = TheArray[i].x) then
          if (ThePoint.y = TheArray[i].y) then
          begin
            Result := True;
            Exit;
          end;
    end;
    :-)

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Just a quick question? Did I say quick?
    By SeanJohn in forum OSR Help
    Replies: 3
    Last Post: 01-28-2009, 12:03 AM
  2. I need some quick help
    By AJ2VM in forum OSR Help
    Replies: 45
    Last Post: 12-19-2007, 03:17 PM
  3. quick ? plz
    By rjbk1989 in forum OSR Help
    Replies: 3
    Last Post: 05-07-2007, 12:43 AM

Posting Permissions

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