hedgewars/GSHandlers.inc
branchicegun
changeset 8583 f2edd6d5f958
parent 8582 08679e8186a3
child 8584 ea20d9cc8515
child 8586 191bd86ba000
equal deleted inserted replaced
8582:08679e8186a3 8583:f2edd6d5f958
  5153     LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[iceSurface^.w * (y mod iceSurface^.h) + (x mod iceSurface^.w)]);
  5153     LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[iceSurface^.w * (y mod iceSurface^.h) + (x mod iceSurface^.w)]);
  5154 
  5154 
  5155     Land[y, x] := land[y, x] or lfIce;
  5155     Land[y, x] := land[y, x] or lfIce;
  5156 end;
  5156 end;
  5157 
  5157 
  5158 procedure DrawIce(Gear: PGear; x, y: Longint); 
  5158 procedure DrawIce(x, y: Longint); 
  5159     const iceSize :Longint = 255;
  5159     const iceRadius :Longint = 32;
  5160     const iceHalfSize :Longint = 127;
       
  5161 var
  5160 var
  5162     i, j: Longint;
  5161     i, j: Longint;
  5163     weight: Longint;
  5162     weight: Longint;
  5164     landRect : TSDL_RECT;
  5163     landRect : TSDL_RECT;
  5165 begin
  5164 begin
  5166     for i := max(x - iceHalfSize, 0) to min(x + iceHalfSize, LAND_WIDTH-1) do
  5165     FillRoundInLandWithIce(x, y, iceRadius);
  5167         begin
       
  5168         for j := max(y - iceHalfSize, 0) to min(y + iceHalfSize, LAND_HEIGHT-1) do 
       
  5169             begin
       
  5170             weight := getPixelWeight(i, j);
       
  5171             if isLandscape(weight) then
       
  5172                 begin
       
  5173                 if Land[j,i] and lfIce = 0 then drawIcePixel(i, j);
       
  5174                 end 
       
  5175             else
       
  5176                 begin
       
  5177                 if isLandscapeEdge(weight) then 
       
  5178                     begin
       
  5179                     LandPixels[j, i] := $FFB2AF8A;                    
       
  5180                     if Land[j, i] > 255 then Land[j, i] := Land[j, i] or lfIce;
       
  5181                     end;                
       
  5182                 end;
       
  5183             end;
       
  5184         end;
       
  5185     SetAllHHToActive; 
  5166     SetAllHHToActive; 
  5186     landRect.x := min(max(x - iceHalfSize, 0), LAND_WIDTH - 1);
  5167     landRect.x := min(max(x - iceRadius, 0), LAND_WIDTH - 1);
  5187     landRect.y := min(max(y - iceHalfSize, 0), LAND_HEIGHT - 1);
  5168     landRect.y := min(max(y - iceRadius, 0), LAND_HEIGHT - 1);
  5188     landRect.w := min(iceSize, LAND_WIDTH - landRect.x - 1);
  5169     landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1);
  5189     landRect.h := min(iceSize, LAND_HEIGHT - landRect.y - 1);
  5170     landRect.h := min(2*iceRadius, LAND_HEIGHT - landRect.y - 1);
  5190     UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);
  5171     UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);
  5191 end;
  5172 end;
  5192 
  5173 
  5193 
  5174 
  5194 procedure doStepIceGun(Gear: PGear);
  5175 procedure doStepIceGun(Gear: PGear);
  5255                     X:= HHGear^.X;
  5236                     X:= HHGear^.X;
  5256                     Y:= HHGear^.Y
  5237                     Y:= HHGear^.Y
  5257                 end;
  5238                 end;
  5258 
  5239 
  5259                 if (IceState = iceCollideWithGround) and ((GameTicks - IceTime) > groundFreezingTime) then
  5240                 if (IceState = iceCollideWithGround) and ((GameTicks - IceTime) > groundFreezingTime) then
  5260                 begin                    
  5241                 begin 
  5261                     DrawIce(Gear, Target.X, Target.Y);                    
  5242                     DrawIce(Target.X, Target.Y);                                        
  5262                     IceState := iceWaitNextTarget;
  5243                     IceState := iceWaitNextTarget;
  5263                 end;
  5244                 end;
  5264 
  5245 
  5265 // freeze nearby hogs
  5246 // freeze nearby hogs
  5266                 hogs := GearsNear(int2hwFloat(Target.X), int2hwFloat(Target.Y), gtHedgehog, Gear^.Radius*2);
  5247                 hogs := GearsNear(int2hwFloat(Target.X), int2hwFloat(Target.Y), gtHedgehog, Gear^.Radius*2);