This adds idle hog tinting. Active hog tinting still needed.
--- a/hedgewars/uGearsList.pas Tue Jan 21 01:38:06 2014 +0100
+++ b/hedgewars/uGearsList.pas Mon Jan 20 21:16:17 2014 -0500
@@ -20,7 +20,7 @@
unit uGearsList;
interface
-uses uFloat, uTypes;
+uses uFloat, uTypes, SDLh;
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
procedure DeleteGear(Gear: PGear);
@@ -156,6 +156,7 @@
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
var gear: PGear;
+ c: byte;
begin
inc(GCounter);
AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
@@ -180,6 +181,7 @@
// Define ammo association, if any.
gear^.AmmoType:= GearKindAmmoTypeMap[Kind];
gear^.CollisionMask:= $FFFF;
+gear^.Tint:= $FFFFFFFF;
if CurrentHedgehog <> nil then
begin
@@ -235,6 +237,18 @@
if (GameFlags and gfAISurvival) <> 0 then
if gear^.Hedgehog^.BotLevel > 0 then
gear^.Hedgehog^.Effects[heResurrectable] := 1;
+ // this would presumably be set in the frontend
+ // if we weren't going to do that yet, would need to reinit GetRandom
+ // oh, and, randomising slightly R and B might be nice too.
+ //gear^.Tint:= $fa00efff or ((random(80)+128) shl 16)
+ //gear^.Tint:= $faa4efff
+ //gear^.Tint:= (($e0+random(32)) shl 24) or
+ // ((random(80)+128) shl 16) or
+ // (($d5+random(32)) shl 8) or $ff
+ c:= random(32);
+ gear^.Tint:= (($e0+c) shl 24) or
+ ((random(90)+128) shl 16) or
+ (($d5+c) shl 8) or $ff
end;
gtShell: begin
gear^.Elasticity:= _0_8;
@@ -272,6 +286,9 @@
Health:= random(vobFrameTicks);
if gear^.Timer = 0 then Timer:= random(vobFramesCount);
Damage:= (random(2) * 2 - 1) * (vobVelocity + random(vobVelocity)) * 8;
+ Tint:= (ExplosionBorderColor and RMask shl RShift) or
+ (ExplosionBorderColor and GMask shl GShift) or
+ (ExplosionBorderColor and BMask shl BShift) or $FF;
end
end;
gtGrave: begin
@@ -400,7 +417,10 @@
gear^.Radius:= 15;
gear^.Tag:= Y
end;
- gtAirAttack: gear^.Z:= cHHZ+2;
+ gtAirAttack: begin
+ gear^.Z:= cHHZ+2;
+ gear^.Tint:= gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF
+ end;
gtAirBomb: begin
gear^.Radius:= 5;
gear^.Density:= _2;
@@ -485,7 +505,8 @@
gtRCPlane: begin
if gear^.Timer = 0 then gear^.Timer:= 15000;
gear^.Health:= 3;
- gear^.Radius:= 8
+ gear^.Radius:= 8;
+ gear^.Tint:= gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF
end;
gtJetpack: begin
gear^.Health:= 2000;
@@ -544,10 +565,12 @@
gtPoisonCloud: begin
if gear^.Timer = 0 then gear^.Timer:= 5000;
gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000;
+ gear^.Tint:= $C0C000C0
end;
gtResurrector: begin
gear^.Radius := 100;
- gear^.Tag := 0
+ gear^.Tag := 0;
+ gear^.Tint:= $F5DB35FF
end;
gtWaterUp: begin
gear^.Tag := 47;
--- a/hedgewars/uGearsRender.pas Tue Jan 21 01:38:06 2014 +0100
+++ b/hedgewars/uGearsRender.pas Mon Jan 20 21:16:17 2014 -0500
@@ -795,13 +795,24 @@
begin
if defaultPos then
begin
- if HH^.Team^.hasGone then Tint($FF, $FF, $FF, $80);
+ if HH^.Team^.hasGone then
+ Tint($FFFFFF80)
+ else if HH^.Effects[hePoisoned] <> 0 then
+ Tint($B7FFBCFF)
+ else Tint(HH^.Gear^.Tint);
DrawSpriteRotatedF(sprHHIdle,
sx,
sy,
(RealTicks div 128 + Gear^.Pos) mod 19,
sign,
0);
+ untint;
+ DrawSpriteRotatedF(sprHHIdle,
+ sx,
+ sy,
+ (RealTicks div 128 + Gear^.Pos) mod 19 + 32,
+ sign,
+ 0);
HatVisible:= true;
end;
@@ -1039,7 +1050,7 @@
gtRCPlane: begin
aangle:= Gear^.Angle * 360 / 4096;
if Gear^.Tag < 0 then aangle:= 360-aangle;
- Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF);
+ Tint(Gear^.Tint);
DrawSpriteRotatedF(sprPlane, x, y, 0, Gear^.Tag, aangle - 90);
untint;
DrawSpriteRotatedF(sprPlane, x, y, 1, Gear^.Tag, aangle - 90)
@@ -1161,7 +1172,7 @@
DrawAltWeapon(Gear, x + 1, y - 3)
end;
gtAirAttack: begin
- Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF);
+ Tint(Gear^.Tint);
DrawSpriteRotatedF(sprAirplane, x, y, 0, Gear^.Tag, 0);
untint;
DrawSpriteRotatedF(sprAirplane, x, y, 1, Gear^.Tag, 0);
@@ -1237,27 +1248,24 @@
end;
gtPoisonCloud: begin
if Gear^.Timer < 1020 then
- Tint($C0, $C0, $00, Gear^.Timer div 8)
+ Tint(Gear^.Tint and $FFFFFF00 or Gear^.Timer div 8)
else if Gear^.Timer > 3980 then
- Tint($C0, $C0, $00, (5000 - Gear^.Timer) div 8)
+ Tint(Gear^.Tint and $FFFFFF00 or (5000 - Gear^.Timer) div 8)
else
- Tint($C0, $C0, $00, $C0);
+ Tint(Gear^.Tint);
DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 3, 0, 0, x, y, 0, 1, 22, 22, (RealTicks shr 36 + Gear^.UID * 100) mod 360);
untint
end;
gtResurrector: begin
DrawSpriteRotated(sprCross, x, y, 0, 0);
- Tint($f5, $db, $35, max($00, round($C0 * abs(1 - (GameTicks mod 6000) / 3000))));
+ Tint(Gear^.Tint and $FFFFFF00 or max($00, round($C0 * abs(1 - (GameTicks mod 6000) / 3000))));
DrawTexture(x - 108, y - 108, SpritesData[sprVampiric].Texture, 4.5);
untint;
end;
gtNapalmBomb: DrawSpriteRotated(sprNapalmBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
gtFlake: if Gear^.State and (gstDrowning or gstTmpFlag) <> 0 then
begin
- Tint((ExplosionBorderColor shr RShift) and $FF,
- (ExplosionBorderColor shr GShift) and $FF,
- (ExplosionBorderColor shr BShift) and $FF,
- $FF);
+ Tint(Gear^.Tint);
// Needs a nicer white texture to tint
DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle);
//DrawSpriteRotated(sprSnowDust, x, y, 0, Gear^.DirAngle);
--- a/hedgewars/uTypes.pas Tue Jan 21 01:38:06 2014 +0100
+++ b/hedgewars/uTypes.pas Mon Jan 20 21:16:17 2014 -0500
@@ -270,6 +270,7 @@
MsgParam: LongWord; // Initially stored a set of messages. So usually gm values like Message. Frequently overriden
// These are not used generically, but should probably be used for purpose intended. Definitely shouldn't override pointer type
Tex: PTexture; // A texture created by the gear. Shouldn't use for anything but textures
+ Tint: LongWord; // Used to colour a texture
LinkedGear: PGear; // Used to track a related gear. Portal pairs for example.
Hedgehog: PHedgehog; // set to CurrentHedgehog on gear creation
SoundChannel: LongInt; // Used to track a sound the gear started
--- a/hedgewars/uWorld.pas Tue Jan 21 01:38:06 2014 +0100
+++ b/hedgewars/uWorld.pas Mon Jan 20 21:16:17 2014 -0500
@@ -655,7 +655,7 @@
DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex);
if ((AMState = AMHiding) or (AMState = AMShowingUp)) and ((AMAnimType and AMTypeMaskAlpha) <> 0 )then
- Tint($FF, $ff, $ff, $ff);
+ untint;
Pos:= -1;
Slot:= -1;
@@ -1333,7 +1333,7 @@
begin
SetScale(cDefaultZoomLevel);
if TeamsCount * 20 > Longword(cScreenHeight) div 5 then
- Tint($FF,$FF,$FF,$FF);
+ untint;
end;
end;
Binary file share/hedgewars/Data/Graphics/Hedgehog/Idle.png has changed