hedgewars/uLandGraphics.pas
branchwebgl
changeset 9168 20ff80421736
parent 9127 e350500c4edb
child 9521 8054d9d775fd
equal deleted inserted replaced
9166:3774ac58e65e 9168:20ff80421736
    38 function  CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean;
    38 function  CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean;
    39 function  DrawExplosion(X, Y, Radius: LongInt): Longword;
    39 function  DrawExplosion(X, Y, Radius: LongInt): Longword;
    40 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
    40 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
    41 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
    41 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
    42 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
    42 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
    43 function FillRoundInLand(X, Y, Radius: LongInt; fill: fillType): LongWord;
    43 function FillRoundInLand2(X, Y, Radius: LongInt; fill: fillType): LongWord;
    44 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean);
    44 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean);
    45 function  LandBackPixel(x, y: LongInt): LongWord;
    45 function  LandBackPixel(x, y: LongInt): LongWord;
    46 procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword);
    46 procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword);
    47 procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword);
    47 procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword);
    48 procedure DumpLandToLog(x, y, r: LongInt);
    48 procedure DumpLandToLog(x, y, r: LongInt);
   238     inc(FillLandCircleSegment, FillLandCircleLine(y + dx, Max(x - dy, 0), Min(x + dy, LAND_WIDTH - 1), fill));
   238     inc(FillLandCircleSegment, FillLandCircleLine(y + dx, Max(x - dy, 0), Min(x + dy, LAND_WIDTH - 1), fill));
   239 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   239 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   240     inc(FillLandCircleSegment, FillLandCircleLine(y - dx, Max(x - dy, 0), Min(x + dy, LAND_WIDTH - 1), fill));
   240     inc(FillLandCircleSegment, FillLandCircleLine(y - dx, Max(x - dy, 0), Min(x + dy, LAND_WIDTH - 1), fill));
   241 end;
   241 end;
   242 
   242 
   243 function FillRoundInLand(X, Y, Radius: LongInt; fill: fillType): Longword; inline;
   243 function FillRoundInLand2(X, Y, Radius: LongInt; fill: fillType): Longword; inline;
   244 var dx, dy, d: LongInt;
   244 var dx, dy, d, r: LongInt;
   245 begin
   245 begin
   246 dx:= 0;
   246 dx:= 0;
   247 dy:= Radius;
   247 dy:= Radius;
   248 d:= 3 - 2 * Radius;
   248 d:= 3 - 2 * Radius;
   249 FillRoundInLand := 0;
   249 r := 0;
   250 while (dx < dy) do
   250 while (dx < dy) do
   251     begin
   251     begin
   252     inc(FillRoundInLand, FillLandCircleSegment(x, y, dx, dy, fill));
   252     inc(r, FillLandCircleSegment(x, y, dx, dy, fill));
   253     if (d < 0) then
   253     if (d < 0) then
   254         d:= d + 4 * dx + 6
   254         d:= d + 4 * dx + 6
   255     else
   255     else
   256         begin
   256         begin
   257         d:= d + 4 * (dx - dy) + 10;
   257         d:= d + 4 * (dx - dy) + 10;
   258         dec(dy)
   258         dec(dy)
   259         end;
   259         end;
   260     inc(dx)
   260     inc(dx)
   261     end;
   261     end;
   262 if (dx = dy) then
   262 if (dx = dy) then
   263     inc (FillRoundInLand, FillLandCircleSegment(x, y, dx, dy, fill));
   263     inc(r, FillLandCircleSegment(x, y, dx, dy, fill));
       
   264 
       
   265 FillRoundInLand2:= r
   264 end;
   266 end;
   265 
   267 
   266 
   268 
   267 function addBgColor(OldColor, NewColor: LongWord): LongWord;
   269 function addBgColor(OldColor, NewColor: LongWord): LongWord;
   268 // Factor ranges from 0 to 100% NewColor
   270 // Factor ranges from 0 to 100% NewColor
   339 end;
   341 end;
   340 
   342 
   341 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean);
   343 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean);
   342 begin
   344 begin
   343 if not doSet and isCurrent then
   345 if not doSet and isCurrent then
   344     FillRoundInLand(X, Y, Radius, setNotCurrentMask)
   346     FillRoundInLand2(X, Y, Radius, setNotCurrentMask)
   345 else if not doSet and (not IsCurrent) then
   347 else if not doSet and (not IsCurrent) then
   346     FillRoundInLand(X, Y, Radius, changePixelSetNotCurrent)
   348     FillRoundInLand2(X, Y, Radius, changePixelSetNotCurrent)
   347 else if doSet and IsCurrent then
   349 else if doSet and IsCurrent then
   348     FillRoundInLand(X, Y, Radius, setCurrentHog)
   350     FillRoundInLand2(X, Y, Radius, setCurrentHog)
   349 else if doSet and (not IsCurrent) then
   351 else if doSet and (not IsCurrent) then
   350     FillRoundInLand(X, Y, Radius, changePixelNotSetNotCurrent);
   352     FillRoundInLand2(X, Y, Radius, changePixelNotSetNotCurrent);
   351 end;
   353 end;
   352 
   354 
   353 procedure DrawIceBreak(x, y, iceRadius, iceHeight: Longint);
   355 procedure DrawIceBreak(x, y, iceRadius, iceHeight: Longint);
   354 var
   356 var
   355     i, j: integer;
   357     i, j: integer;
   375 
   377 
   376 function DrawExplosion(X, Y, Radius: LongInt): Longword;
   378 function DrawExplosion(X, Y, Radius: LongInt): Longword;
   377 var
   379 var
   378     tx, ty, dx, dy: Longint;
   380     tx, ty, dx, dy: Longint;
   379 begin
   381 begin
   380     DrawExplosion := FillRoundInLand(x, y, Radius, backgroundPixel);
   382     DrawExplosion := FillRoundInLand2(x, y, Radius, backgroundPixel);
   381     if Radius > 20 then
   383     if Radius > 20 then
   382         FillRoundInLand(x, y, Radius - 15, nullPixel);
   384         FillRoundInLand2(x, y, Radius - 15, nullPixel);
   383     FillRoundInLand(X, Y, Radius, 0);
   385     FillRoundInLand(X, Y, Radius, 0);
   384     FillRoundInLand(x, y, Radius + 4, ebcPixel);
   386     FillRoundInLand2(x, y, Radius + 4, ebcPixel);
   385     tx:= Max(X - Radius - 5, 0);
   387     tx:= Max(X - Radius - 5, 0);
   386     dx:= Min(X + Radius + 5, LAND_WIDTH) - tx;
   388     dx:= Min(X + Radius + 5, LAND_WIDTH) - tx;
   387     ty:= Max(Y - Radius - 5, 0);
   389     ty:= Max(Y - Radius - 5, 0);
   388     dy:= Min(Y + Radius + 5, LAND_HEIGHT) - ty;
   390     dy:= Min(Y + Radius + 5, LAND_HEIGHT) - ty;
   389     UpdateLandTexture(tx, dx, ty, dy, false);
   391     UpdateLandTexture(tx, dx, ty, dy, false);