--- a/hedgewars/uVisualGears.pas Mon Nov 29 09:11:31 2010 +0100
+++ b/hedgewars/uVisualGears.pas Tue Nov 30 22:46:47 2010 +0100
@@ -20,36 +20,12 @@
unit uVisualGears;
interface
-uses uConsts, uFloat, Math, GLunit;
-
-type PVisualGear = ^TVisualGear;
- TVGearStepProcedure = procedure (Gear: PVisualGear; Steps: Longword);
- TVisualGear = record
- NextGear, PrevGear: PVisualGear;
- Frame,
- FrameTicks: Longword;
- X : float;
- Y : float;
- dX: float;
- dY: float;
- tdX: float;
- tdY: float;
- State : Longword;
- Timer: Longword;
- Angle, dAngle: real;
- Kind: TVisualGearType;
- doStep: TVGearStepProcedure;
- Tex: PTexture;
- alpha, scale: GLfloat;
- Hedgehog: pointer;
- Text: shortstring;
- Tint: Longword;
- end;
+uses uConsts, uFloat, GLunit, uTypes;
procedure initModule;
procedure freeModule;
-function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0): PVisualGear;
+function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0; Critical: Boolean = false): PVisualGear;
procedure ProcessVisualGears(Steps: Longword);
procedure KickFlakes(Radius, X, Y: LongInt);
procedure DrawVisualGears(Layer: LongWord);
@@ -57,12 +33,9 @@
procedure AddClouds;
procedure AddDamageTag(X, Y, Damage, Color: LongWord);
-var VisualGearsList: PVisualGear;
- vobFrameTicks, vobFramesCount, vobCount: Longword;
- vobVelocity, vobFallSpeed: LongInt;
+implementation
+uses uSound, uMobile, uVariables, uTextures, uRender, Math, uRenderUtils;
-implementation
-uses uWorld, uMisc, uStore, uTeams, uSound, uMobile;
const cExplFrameTicks = 110;
{$INCLUDE "VGSHandlers.inc"}
@@ -119,22 +92,25 @@
@doStepChunk,
@doStepNote,
@doStepLineTrail,
- @doStepBulletHit
+ @doStepBulletHit,
+ @doStepCircle
);
-function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0): PVisualGear;
+function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0; Critical: Boolean = false): PVisualGear;
+const VGCounter: Longword = 0;
var gear: PVisualGear;
t: Longword;
- sp: float;
+ sp: real;
begin
if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then // we are scrolling now
- if Kind <> vgtCloud then
+ if (Kind <> vgtCloud) and not Critical then
begin
AddVisualGear:= nil;
exit
end;
if ((cReducedQuality and rqFancyBoom) <> 0) and
+ not Critical and
not (Kind in
[vgtTeamHealthSorter,
vgtSmallDamageTag,
@@ -149,14 +125,16 @@
exit
end;
+inc(VGCounter);
New(gear);
FillChar(gear^, sizeof(TVisualGear), 0);
-gear^.X:= float(X);
-gear^.Y:= float(Y);
+gear^.X:= real(X);
+gear^.Y:= real(Y);
gear^.Kind := Kind;
gear^.doStep:= doStepHandlers[Kind];
gear^.State:= 0;
gear^.Tint:= $FFFFFFFF;
+gear^.uid:= VGCounter;
with gear^ do
case Kind of
@@ -378,7 +356,7 @@
if Gear^.Kind = vgtFlake then
begin
// Damage calc from doMakeExplosion
- dmg:= min(101, Radius + cHHRadius div 2 - LongInt(abs(round(Gear^.X) - X) + abs(round(Gear^.Y) - Y)) div 5);
+ dmg:= Min(101, Radius + cHHRadius div 2 - LongInt(abs(round(Gear^.X) - X) + abs(round(Gear^.Y) - Y)) div 5);
if dmg > 1 then
begin
Gear^.tdX:= 0.02 * dmg + 0.01;
@@ -436,7 +414,7 @@
case Gear^.Kind of
vgtExplosion: DrawSprite(sprExplosion50, round(Gear^.X) - 32 + WorldDx, round(Gear^.Y) - 32 + WorldDy, Gear^.State);
vgtBigExplosion: begin
- Tint($FF, $FF, $FF, floor($FF * (1 - power(Gear^.Timer / 250, 4))));
+ Tint($FF, $FF, $FF, round($FF * (1 - power(Gear^.Timer / 250, 4))));
DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
end;
end;
@@ -451,14 +429,14 @@
vgtBubble: DrawSprite(sprBubbles, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
vgtSteam: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
vgtAmmo: begin
- Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
+ Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
DrawTextureF(ropeIconTex, Gear^.scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 32, 32);
DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
end;
vgtHealth: begin
case Gear^.Frame div 10 of
- 0:Tint(0, $FF, 0, floor(Gear^.FrameTicks * $FF / 1000));
- 1:Tint($FF, 0, 0, floor(Gear^.FrameTicks * $FF / 1000));
+ 0:Tint(0, $FF, 0, round(Gear^.FrameTicks * $FF / 1000));
+ 1:Tint($FF, 0, 0, round(Gear^.FrameTicks * $FF / 1000));
end;
DrawSprite(sprHealth, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, 0);
end;
@@ -482,7 +460,7 @@
DrawRotatedF(sprBeeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
end;
vgtSmokeRing: begin
- Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
+ Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
end;
vgtChunk: DrawRotatedF(sprChunk, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
@@ -493,6 +471,9 @@
vgtSmallDamageTag: DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
vgtHealthTag: if Gear^.Tex <> nil then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
+ vgtCircle: DrawCircle(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State, Gear^.Timer,
+ ((Gear^.Tint shr 24) and $FF), ((Gear^.Tint shr 16) and $FF), ((Gear^.Tint shr 8) and $FF), Gear^.Tint and $FF);
+// Consider adding a version of DrawCircle that does not set Tint internally, and just call it here...
end;
Gear:= Gear^.NextGear
end