hedgewars/uLandObjects.pas
changeset 56 a29135563e94
parent 54 839fd258ae6f
child 70 82d93eeecebe
equal deleted inserted replaced
55:e09f7c952a40 56:a29135563e94
    50                     Surf: PSDL_Surface;
    50                     Surf: PSDL_Surface;
    51                     inland: TSDL_Rect;
    51                     inland: TSDL_Rect;
    52                     outland: array[1..MAXOBJECTRECTS] of TSDL_Rect;
    52                     outland: array[1..MAXOBJECTRECTS] of TSDL_Rect;
    53                     rectcnt: Longword;
    53                     rectcnt: Longword;
    54                     Width, Height: Longword;
    54                     Width, Height: Longword;
       
    55                     Maxcnt: Longword;
    55                     end;
    56                     end;
    56 
    57 
    57 var Rects: PRectArray;
    58 var Rects: PRectArray;
    58     RectCount: Longword;
    59     RectCount: Longword;
    59 
    60 
   253     cnt, i: Longword;
   254     cnt, i: Longword;
   254 begin
   255 begin
   255 cnt:= 0;
   256 cnt:= 0;
   256 with Obj do
   257 with Obj do
   257      begin
   258      begin
       
   259      if Maxcnt = 0 then
       
   260         begin
       
   261         Result:= false;
       
   262         exit
       
   263         end;
   258      x:= 0;
   264      x:= 0;
   259      repeat
   265      repeat
   260          y:= 0;
   266          y:= 0;
   261          repeat
   267          repeat
   262              if CheckCanPlace(x, y, Obj) then
   268              if CheckCanPlace(x, y, Obj) then
   278      if Result then
   284      if Result then
   279         begin
   285         begin
   280         i:= getrandom(cnt);
   286         i:= getrandom(cnt);
   281         BlitImageAndGenerateCollisionInfo(ar[i].x, ar[i].y, Obj.Surf, Surface);
   287         BlitImageAndGenerateCollisionInfo(ar[i].x, ar[i].y, Obj.Surf, Surface);
   282         AddRect(ar[i].x, ar[i].y, Width, Height);
   288         AddRect(ar[i].x, ar[i].y, Width, Height);
   283         end
   289         dec(Maxcnt)
       
   290         end else Maxcnt:= 0
   284      end
   291      end
   285 end;
   292 end;
   286 
   293 
   287 procedure AddThemeObjects(Surface: PSDL_Surface; MaxCount: Longword);
   294 procedure AddThemeObjects(Surface: PSDL_Surface; MaxCount: Longword);
   288 const MAXTHEMEOBJECTS = 32;
   295 const MAXTHEMEOBJECTS = 32;
   308          Read(f, Width, Height);
   315          Read(f, Width, Height);
   309          with inland do Read(f, x, y, w, h);
   316          with inland do Read(f, x, y, w, h);
   310          Read(f, rectcnt);
   317          Read(f, rectcnt);
   311          for ii:= 1 to rectcnt do
   318          for ii:= 1 to rectcnt do
   312              with outland[ii] do Read(f, x, y, w, h);
   319              with outland[ii] do Read(f, x, y, w, h);
       
   320          Maxcnt:= 2;
   313          ReadLn(f)
   321          ReadLn(f)
   314          end;
   322          end;
   315     end;
   323     end;
   316 Closefile(f);
   324 Closefile(f);
   317 {$I+}
   325 {$I+}