All pastes #450887 Raw Edit

Mine

public text v1 · immutable
·published 2007-04-21 03:29 UTC
rendered paste body
program New;
{.include SRL/SRL.scar}

type TpointColor=record
point:tpoint;
color:integer;
end;

type PlayerDot=record
Pixels:array of TpointColor;
Point:tpoint;
end;


{*******************************************************************************
function tPtArrayToStr(newTPoint: TPointarray): String;
By: moparisthebest
Description: Loads a TPointArray into a string. (Example String: '50,10 80,53 350,765 8560,1897 2348,346')
*******************************************************************************}

function tPtArrayToStr(newTPoint: TPointArray): string;
var
  i, tPtLength: Integer;
begin
  tPtLength := GetArrayLength(newTPoint);
  repeat
    Result := Result + IntToStr(newTPoint[i].x) + ',' +
      IntToStr(newTPoint[i].y);
    if (not (i = (tPtLength - 1))) then
      Result := Result + ' ';
    i := i + 1;
  until (i = tPtLength)
end;


function FindAllBitmapsIn(TheBmp,startx,starty,endx,endy:integer):array of tpoint;
var tmpbool:boolean;
AL:integer;
curx,cury,tmpx,tmpy,height:integer;
begin
  tmpbool:=FindBitmapIn(TheBmp,tmpx,tmpy,startx,starty,endx,endy);
  if tmpbool then
  begin
    curx:=startx;
    cury:=starty;
    /////auto height finder///////
    tmpbool:=FindBitmapIn(TheBmp,tmpx,tmpy,startx,starty,endx,endy);
    height:=0;
    repeat
      height:=height+1;
      tmpbool:=FindBitmapIn(TheBmp,tmpx,tmpy,startx,tmpy,endx,tmpy+height);
    until tmpbool;
    //writeln('height '+inttostr(height));
    ///////////
    repeat
      tmpbool:=FindBitmapIn(TheBmp,tmpx,tmpy,curx,cury,endx,cury+height);
      if tmpbool then
      begin
        curx:=tmpx+1;
        AL:=getarraylength(result);
        setarraylength(result,AL+1);
        result[AL].x:=tmpx;
        result[AL].y:=tmpy;
      end;
      if not tmpbool then
      begin
        curx:=startx;
        cury:=cury+1;
      end;
    until cury=endy+1;
  end;
end;

function XYToTP(TheX,They:integer):Tpoint;
begin
  result.x:=TheX;
  result.y:=They;
end;


procedure AddPlayerDotToPDA(locx,locy:integer; var ThePDA:array of PlayerDot);
var AL:integer;
TheTPCA:array of tpointcolor;
begin

AL:=0;//getarraylength(ThePDA);
setarraylength(TheTPCA,AL+16);
TheTPCA[AL].point:=xyToTP(locx+2,locy);
TheTPCA[AL].color:=16711422;
TheTPCA[AL+1].point:=xyToTP(locx+2,locy+1);
TheTPCA[AL+1].color:=16711422;
TheTPCA[AL+2].point:=xyToTP(locx+2,locy+2);
TheTPCA[AL+2].color:=15527148;
TheTPCA[AL+3].point:=xyToTP(locx+2,locy+3);
TheTPCA[AL+3].color:=12961221;
TheTPCA[AL+4].point:=xyToTP(locx+2,locy+4);
TheTPCA[AL+4].color:=65536;

TheTPCA[AL+5].point:=xyToTP(locx+1,locy);
TheTPCA[AL+5].color:=16711422;
TheTPCA[AL+6].point:=xyToTP(locx+1,locy+1);
TheTPCA[AL+6].color:=16711422
TheTPCA[AL+7].point:=xyToTP(locx+1,locy+2);
TheTPCA[AL+7].color:=16711422;
TheTPCA[AL+8].point:=xyToTP(locx+1,locy+3);
TheTPCA[AL+8].color:=14869218;
TheTPCA[AL+9].point:=xyToTP(locx+1,locy+4);
TheTPCA[AL+9].color:=65536;

TheTPCA[AL+10].point:=xyToTP(locx,locy+1);
TheTPCA[AL+10].color:=16711422;
TheTPCA[AL+11].point:=xyToTP(locx,locy+2);
TheTPCA[AL+11].color:=16711422;
TheTPCA[AL+12].point:=xyToTP(locx,locy+3);
TheTPCA[AL+12].color:=65536;

TheTPCA[AL+13].point:=xyToTP(locx+3,locy+1);
TheTPCA[AL+13].color:=15527148;
TheTPCA[AL+14].point:=xyToTP(locx+3,locy+2);
TheTPCA[AL+14].color:=13816530;
TheTPCA[AL+15].point:=xyToTP(locx+3,locy+3);
TheTPCA[AL+15].color:=65536;

AL:=getarraylength(ThePDA);
setarraylength(ThePDA,AL+1);
setarraylength(ThePDA[AL].pixels,16);

ThePDA[AL].pixels:=TheTPCA;
ThePDA[AL].point:=xyToTP(locx,locy);

end;



 var mytpa,listofpts,NewTPA:array of tpoint;
  MyPDA,NewPDA:array of PlayerDot;
 t,time,tal,oal,AL,parrayold,parraytemp,iter,PlayerDot:integer;

Var DebugCanvas,BmpCanvas:TCanvas;
procedure AddArray (WhichTPA:array of tpoint; WhichColor:integer);
var parray, arraylength:integer;
begin
  arraylength:=getarraylength(whichtpa);
  for parray:=0 to arraylength-1 do
    bmpcanvas.pixels[whichtpa[parray].x-576+5,whichtpa[parray].y-9+5]:=WhichColor;
  Copycanvas(BmpCanvas,DebugCanvas,0,0,150,157,5,5,155,162)
end;


procedure StartMiniMapDebug;
Var bmpBlankMap:integer;
begin {
  bmpBlankMap:= LoadBitmap(apppath+'test.bmp');
  DisplayDebugImgWindow(160,167) //to show the canvas
  DebugCanvas:=getdebugcanvas //gets the referance to the debug image and stores in that varaible
  BmpCanvas:=GetBitmapCanvas(bmpBlankMap)//gets the regerance to the bmp and stores in that variable
  BlankMapCanvas:=GetBitmapCanvas(bmpBlankMap);
  Copycanvas(BmpCanvas,DebugCanvas,0,0,150,157,5,5,155,162)
  FreeBitmap(bmpBlankMap);

   }
  bmpBlankMap:= LoadBitmap(apppath+'test.bmp');
DisplayDebugImgWindow(160,167) //to show the canvas
DebugCanvas:=getdebugcanvas //gets the referance to the debug image and stores in that varaible
BmpCanvas:=GetBitmapCanvas(bmpBlankMap)//gets the regerance to the bmp and stores in that variable
Copycanvas(BmpCanvas,DebugCanvas,0,0,150,157,5,5,155,162)

end;

begin
  SetupSRL;

  PlayerDot := BitmapFromString(4, 5, 'z78DA3330000137570434C010' +
       '8140576710C41471310241B026435723107436054188880102182' +
       '28B0000E71C1BCB');
  time:=getsystemtime;
  if findbitmap(playerdot,x,y) then
  begin
  mytpa:= FindAllBitmapsIn(PlayerDot,mmx1,mmy1,mmx2,mmy2);

  for iter:= 0 to getarraylength(mytpa)-1 do
    AddPlayerDotToPDA(mytpa[iter].x,mytpa[iter].y,MyPDA);
  end;
  //writeln(inttostr(getarraylength(mytpa)));
  //writeln(inttostr(getarraylength(mytpca)));
  //writeln(inttostr(getarraylength(mypda)));
   StartMiniMapDebug
//for iter:=0 to getarraylength(MyPDA)-1 do

 // writeln(inttostr(mypda[iter].point.x)+','+inttostr(mypda[iter].point.y));

  for iter:=0 to getarraylength(MyPDA)-1 do
  begin
  //iter:=0;
 // repeat
  // writeln(inttostr(iter));
   for t:=0 to getarraylength(MyPDA[iter].pixels)-1 do
   begin
     AL:=getarraylength(listofpts )
     setarraylength(listofpts,AL+1)
     listofpts[AL]:=MyPDA[iter].pixels[t].point;
   end;
 //  iter:=iter+1;
 //  until iter=getarraylength(mypda);
  end;
  AddArray(listofpts,65280);
 // writeln(inttostr(AL));
  writeln(inttostr(getsystemtime-time)+'ms');


   {
  if findbitmap(playerdot,x,y) then
  begin
  newtpa:= FindAllBitmapsIn(PlayerDot,mmx1,mmy1,mmx2,mmy2);
  for iter:= 0 to getarraylength(newtpa)-1 do
    AddPlayerDotToPDA(newtpa[iter].x,newtpa[iter].y,NewPDA);
  end;
  
  oal:=getarraylength(NewPDA);
  parrayold:=-1;
  repeat
    parrayold:=parrayold+1;
    parraytemp:=-1;
    tmpbool:=false;
    repeat
      parraytemp:=parraytemp+1;
      if (MyPDA[parrayold].point.x=NewPDA[parraytemp].point.x) and (MyPDA[parrayold].point.y=NewPDA[parraytemp].point.y) then
        tmpbool:=true;
    until parrayold=getarraylength(NewPDA)-1;
    if not tmpbool then
    begin
       // go through the pixels in that old point
       // if there are not in pixels of tmp, then get color,
       // replace in bitmap, take out of array
       // if pixel array is empty, tak out dot from pda
    end;
    
  until parrayold=getarraylength(MyPDA)-1;
        }
end.