Jump to content
LordJashin

CheckAllColorsInTPA / New DTM system idea

Recommended Posts

So the idea is to make a new DTM system, that can find them Rotated as well. I wrote up numerous skeletons before, and tried hard. Then I realized I need a new function.

 

function CheckAllColorsInTPA(Colors: TIntArray; TPA: TPointArray): Boolean;:

 

So basically, I want this to return TRUE, if all the colors are found at the points specified in the TPA. Not just if one color is found, and not the others.

 

Here it is:

[scar]

function CheckAllColorsInTPA(Colors: TIntArray; TPA: TPointArray): Boolean;

begin

Result := False;

for i := 0 to high(Colors) do

for j := 0 to high(TPA) do

if not FindColor(x, y, Colors, TPA[j].X, TPA[j].Y, TPA[j].X, TPA[j].Y) then Exit

Result := True;

end;

[/scar]

 

New DTM system w/ rotation:

1. Gather all the points and with rotation as the (Difference array) Which means the difference of SubPoints to MainPoint in the DTM (x, y diff)

Takes about a second for 0-359 rotation and 0.1 angle stepping (can all be done at script start)

2. Gather colors into an array, so now we have a Colors array, and one with all the SubPoints

3. Find the MainPoint on the screen

4. Then Duplicate the SubPoint array, and offset it by where the MainPoint was found

5. Then check if the colors are found correctly with the subpoints

6. If found then return w/e

 

This is a good basis idea. I can think of some better ways to improve this. It all comes down to improving the color stuff/arrays.....

Link to comment
Share on other sites

Welcome back LJ!

Glad to see you are working on this project again, hopefully with good results. :P

 

The only thing I would change for CheckAllColorsInTPA, would be this:

 

function CheckAllColorsInTPA(Colors: TIntArray; TPA: TPointArray): Boolean;
var
 i, j, h1, h2: Integer;
begin
 Result := False;
 h1 := High(Colors);
 h2 := High(TPA);
 for i := 0 to h1 do
   for j := 0 to h2 do
     if not FindColor(x, y, Colors[i], TPA[j].X, TPA[j].Y, TPA[j].X, TPA[j].Y) then
       Exit;
 Result := True;
end;

 

Nice function btw!

 

-Jani

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...