hedgewars/GSHandlers.inc
branchicegun
changeset 8586 191bd86ba000
parent 8583 f2edd6d5f958
child 8588 47084c6fcb4e
equal deleted inserted replaced
8585:da608f69d853 8586:191bd86ba000
  5123            result := result + 1;
  5123            result := result + 1;
  5124            end;
  5124            end;
  5125         end;
  5125         end;
  5126 end;
  5126 end;
  5127 
  5127 
  5128 
       
  5129 procedure drawIcePixel(x, y:Longint);
       
  5130 var 
       
  5131     iceSurface: PSDL_Surface;
       
  5132     icePixels: PLongwordArray;
       
  5133     pictureX, pictureY: LongInt;
       
  5134     w, c: LongWord;
       
  5135 begin
       
  5136 // So. 3 parameters here. Ice colour, Ice opacity, and a bias on the greyscaled pixel towards lightness
       
  5137     c:= $7dc1ccff;
       
  5138     // FIXME should be a global value, not set every single pixel.  Just for test purposes
       
  5139     c:= ($44 shl RShift) or ($97 shl GShift) or ($A9 shl BShift) or ($A0 shl AShift);
       
  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, c);
       
  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;
       
  5157 
       
  5158 procedure DrawIce(x, y: Longint); 
       
  5159     const iceRadius :Longint = 32;
       
  5160 var
       
  5161     i, j: Longint;
       
  5162     weight: Longint;
       
  5163     landRect : TSDL_RECT;
       
  5164 begin
       
  5165     FillRoundInLandWithIce(x, y, iceRadius);
       
  5166     SetAllHHToActive; 
       
  5167     landRect.x := min(max(x - iceRadius, 0), LAND_WIDTH - 1);
       
  5168     landRect.y := min(max(y - iceRadius, 0), LAND_HEIGHT - 1);
       
  5169     landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1);
       
  5170     landRect.h := min(2*iceRadius, LAND_HEIGHT - landRect.y - 1);
       
  5171     UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);
       
  5172 end;
       
  5173 
       
  5174 
       
  5175 procedure doStepIceGun(Gear: PGear);
  5128 procedure doStepIceGun(Gear: PGear);
  5176 const iceWaitCollision:Longint = 0;
  5129 const iceWaitCollision:Longint = 0;
  5177 const iceCollideWithGround:Longint = 1;
  5130 const iceCollideWithGround:Longint = 1;
  5178 const iceWaitNextTarget:Longint = 2;
  5131 const iceWaitNextTarget:Longint = 2;
  5179 const iceCollideWithHog:Longint = 4;
  5132 const iceCollideWithHog:Longint = 4;
  5180 const groundFreezingTime:Longint = 1000;
  5133 const groundFreezingTime:Longint = 1000;
       
  5134 const iceRadius:Longint = 32;
  5181 var
  5135 var
  5182     HHGear: PGear;
  5136     HHGear: PGear;
  5183     ndX, ndY: hwFloat;
  5137     ndX, ndY: hwFloat;
  5184     i, t, gX, gY: LongInt;
  5138     i, t, gX, gY: LongInt;
  5185     hogs: PGearArrayS;
  5139     hogs: PGearArrayS;
  5237                     Y:= HHGear^.Y
  5191                     Y:= HHGear^.Y
  5238                 end;
  5192                 end;
  5239 
  5193 
  5240                 if (IceState = iceCollideWithGround) and ((GameTicks - IceTime) > groundFreezingTime) then
  5194                 if (IceState = iceCollideWithGround) and ((GameTicks - IceTime) > groundFreezingTime) then
  5241                 begin 
  5195                 begin 
  5242                     DrawIce(Target.X, Target.Y);                                        
  5196                     FillRoundInLandWithIce(Target.X, Target.Y, iceRadius);                                        
       
  5197                     SetAllHHToActive; 
  5243                     IceState := iceWaitNextTarget;
  5198                     IceState := iceWaitNextTarget;
  5244                 end;
  5199                 end;
  5245 
  5200 
  5246 // freeze nearby hogs
  5201 // freeze nearby hogs
  5247                 hogs := GearsNear(int2hwFloat(Target.X), int2hwFloat(Target.Y), gtHedgehog, Gear^.Radius*2);
  5202                 hogs := GearsNear(int2hwFloat(Target.X), int2hwFloat(Target.Y), gtHedgehog, Gear^.Radius*2);