hedgewars/GSHandlers.inc
changeset 8599 6bd1950de78b
parent 8589 3bb505fc707e
child 8601 7668f92734b8
equal deleted inserted replaced
8598:9d21bab30893 8599:6bd1950de78b
  5087         iter^.Hedgehog^.Effects[heFrozen]:= 0;
  5087         iter^.Hedgehog^.Effects[heFrozen]:= 0;
  5088         iter:= iter^.NextGear
  5088         iter:= iter^.NextGear
  5089         end 
  5089         end 
  5090 *)
  5090 *)
  5091   end;
  5091   end;
  5092 end;
       
  5093 
       
  5094 
       
  5095 function isLandscapeEdge(weight:Longint):boolean;
       
  5096 begin
       
  5097     result := (weight < 8) and (weight >= 2);
       
  5098 end;
       
  5099 
       
  5100 function isLandscape(weight:Longint):boolean;
       
  5101 begin
       
  5102     result := weight < 2;
       
  5103 end;
       
  5104 
       
  5105 function isEmptySpace(weight:Longint):boolean;
       
  5106 begin
       
  5107     result := not isLandscape(weight) and not isLandscapeEdge(weight);
       
  5108 end;
       
  5109 
       
  5110 
       
  5111 function getPixelWeight(x, y:Longint): Longint;
       
  5112 var
       
  5113     i, j:Longint;
       
  5114 begin    
       
  5115     result := 0;
       
  5116     for i := x - 1 to x + 1 do
       
  5117         for j := y - 1 to y + 1 do 
       
  5118         begin
       
  5119         if (i < 0) or 
       
  5120            (i > LAND_WIDTH - 1) or 
       
  5121            (j < 0) or 
       
  5122            (j > LAND_HEIGHT -1) or 
       
  5123            ((Land[j, i] and $FF00) = 0) then
       
  5124            begin
       
  5125            result := result + 1;
       
  5126            end;
       
  5127         end;
       
  5128 end;
       
  5129 
       
  5130 
       
  5131 procedure drawIcePixel(x, y:Longint);
       
  5132 var 
       
  5133     iceSurface: PSDL_Surface;
       
  5134     icePixels: PLongwordArray;
       
  5135     pictureX, pictureY: LongInt;
       
  5136     w, c: LongWord;
       
  5137 begin
       
  5138     if Land[y, x] and lfIce <> 0 then exit;
       
  5139 // So. 3 parameters here. Ice colour, Ice opacity, and a bias on the greyscaled pixel towards lightness
       
  5140     iceSurface:= SpritesData[sprIceTexture].Surface;
       
  5141     pictureX := x mod iceSurface^.w;
       
  5142     pictureY := y mod iceSurface^.h;
       
  5143     icePixels := iceSurface^.pixels;
       
  5144     w:= LandPixels[y, x];
       
  5145     w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED +
       
  5146           (w shr BShift and $FF) * RGB_LUMINANCE_GREEN +
       
  5147           (w shr GShift and $FF) * RGB_LUMINANCE_BLUE));
       
  5148     if w < 128 then w:= w+128;
       
  5149     if w > 255 then w:= 255;
       
  5150     w:= (w shl RShift) or (w shl BShift) or (w shl GShift) or (LandPixels[y,x] and AMask);
       
  5151     //LandPixels[y, x]:= w;
       
  5152     LandPixels[y, x]:= addBgColor(w, IceColor);
       
  5153     LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[iceSurface^.w * (y mod iceSurface^.h) + (x mod iceSurface^.w)]);
       
  5154 
       
  5155     Land[y, x] := Land[y, x] or lfIce;
       
  5156 end;
  5092 end;
  5157 
  5093 
  5158 procedure DrawIce(x, y: Longint); 
  5094 procedure DrawIce(x, y: Longint); 
  5159     const iceRadius :Longint = 32;
  5095     const iceRadius :Longint = 32;
  5160 var
  5096 var