hedgewars/uLandGraphics.pas
changeset 4791 458d9854c679
parent 4700 e8fd20b2d66b
child 4886 e3e5362a308e
equal deleted inserted replaced
4790:4cb3f7890fbd 4791:458d9854c679
    25 type PRangeArray = ^TRangeArray;
    25 type PRangeArray = ^TRangeArray;
    26      TRangeArray = array[0..31] of record
    26      TRangeArray = array[0..31] of record
    27                                    Left, Right: LongInt;
    27                                    Left, Right: LongInt;
    28                                    end;
    28                                    end;
    29 
    29 
       
    30 function  addBgColor(OldColor, NewColor: LongWord): LongWord;
    30 function  SweepDirty: boolean;
    31 function  SweepDirty: boolean;
    31 function  Despeckle(X, Y: LongInt): boolean;
    32 function  Despeckle(X, Y: LongInt): boolean;
    32 function  CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean;
    33 function  CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean;
    33 function  DrawExplosion(X, Y, Radius: LongInt): Longword;
    34 function  DrawExplosion(X, Y, Radius: LongInt): Longword;
    34 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
    35 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
    39 
    40 
    40 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
    41 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
    41 
    42 
    42 implementation
    43 implementation
    43 uses SDLh, uLandTexture, uVariables, uUtils, uDebug;
    44 uses SDLh, uLandTexture, uVariables, uUtils, uDebug;
       
    45 
       
    46 function addBgColor(OldColor, NewColor: LongWord): LongWord;
       
    47 // Factor ranges from 0 to 100% NewColor
       
    48 var
       
    49     oRed, oBlue, oGreen, oAlpha, nRed, nBlue, nGreen, nAlpha: Byte;
       
    50 begin
       
    51     // Get colors
       
    52     oAlpha := (OldColor shr 24) and $FF;
       
    53     oRed   := (OldColor shr 16) and $FF;
       
    54     oGreen := (OldColor shr 8) and $FF;
       
    55     oBlue  := (OldColor) and $FF;
       
    56 
       
    57     nAlpha := (NewColor shr 24) and $FF;
       
    58     nRed   := (NewColor shr 16) and $FF;
       
    59     nGreen := (NewColor shr 8) and $FF;
       
    60     nBlue  := (NewColor) and $FF;
       
    61 
       
    62     // Mix colors
       
    63     nAlpha := min(255, oAlpha + nAlpha);
       
    64     nRed   := ((oRed * oAlpha) + (nRed * (255-oAlpha))) div 255;
       
    65     nGreen := ((oGreen * oAlpha) + (nGreen * (255-oAlpha))) div 255;
       
    66     nBlue  := ((oBlue * oAlpha) + (nBlue * (255-oAlpha))) div 255;
       
    67 
       
    68     addBgColor := (nAlpha shl 24) or (nRed shl 16) or (nGreen shl 8) or (nBlue);
       
    69 end;
    44 
    70 
    45 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
    71 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
    46 var i: LongInt;
    72 var i: LongInt;
    47 begin
    73 begin
    48 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    74 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then