--- a/hedgewars/VGSHandlers.inc Mon Jan 16 10:22:21 2012 +0100
+++ b/hedgewars/VGSHandlers.inc Tue Jan 17 09:01:31 2012 -0500
@@ -38,13 +38,15 @@
begin
dec(FrameTicks, vobFrameTicks);
inc(Frame);
- if Frame = vobFramesCount then Frame:= 0
+ if Frame = vobFramesCount then
+ Frame:= 0
end
else if SuddenDeathDmg and (FrameTicks > vobSDFrameTicks) then
begin
dec(FrameTicks, vobSDFrameTicks);
inc(Frame);
- if Frame = vobSDFramesCount then Frame:= 0
+ if Frame = vobSDFramesCount then
+ Frame:= 0
end;
X:= X + (cWindSpeedf * 400 + dX + tdX) * Steps * Gear^.Scale;
if SuddenDeathDmg then
@@ -59,28 +61,39 @@
Angle:= Angle + 360;
- if (round(X) >= cLeftScreenBorder) and
- (round(X) <= cRightScreenBorder) and
- (round(Y) - 75 <= LAND_HEIGHT) and
- (Timer > 0) and (Timer-Steps > 0) then
+ if (round(X) >= cLeftScreenBorder)
+ and (round(X) <= cRightScreenBorder)
+ and (round(Y) - 75 <= LAND_HEIGHT)
+ and (Timer > 0) and (Timer-Steps > 0) then
begin
- if tdX > 0 then sign := 1
- else sign:= -1;
+ if tdX > 0 then
+ sign := 1
+ else
+ sign:= -1;
tdX:= tdX - 0.005*Steps*sign;
- if ((sign < 0) and (tdX > 0)) or ((sign > 0) and (tdX < 0)) then tdX:= 0;
- if tdX > 0 then sign := 1
- else sign:= -1;
+ if ((sign < 0) and (tdX > 0)) or ((sign > 0) and (tdX < 0)) then
+ tdX:= 0;
+ if tdX > 0 then
+ sign := 1
+ else
+ sign:= -1;
tdY:= tdY - 0.005*Steps*sign;
- if ((sign < 0) and (tdY > 0)) or ((sign > 0) and (tdY < 0)) then tdY:= 0;
+ if ((sign < 0) and (tdY > 0)) or ((sign > 0) and (tdY < 0)) then
+ tdY:= 0;
dec(Timer, Steps)
end
else
begin
- if round(X) < cLeftScreenBorder then X:= X + cScreenSpace else
- if round(X) > cRightScreenBorder then X:= X - cScreenSpace;
- // if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + 25.0; // For if flag is set for flakes rising upwards?
- if (Gear^.Layer = 2) and (round(Y) - 225 > LAND_HEIGHT) then Y:= Y - (1024 + 300) // TODO - configure in theme (jellies for example could use limited range)
- else if (Gear^.Layer <> 2) and (round(Y) + 50 > LAND_HEIGHT) then Y:= Y - (1024 + 25);
+ if round(X) < cLeftScreenBorder then
+ X:= X + cScreenSpace
+ else
+ if round(X) > cRightScreenBorder then
+ X:= X - cScreenSpace;
+ // if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + 25.0; // For if flag is set for flakes rising upwards?
+ if (Gear^.Layer = 2) and (round(Y) - 225 > LAND_HEIGHT) then
+ Y:= Y - (1024 + 300) // TODO - configure in theme (jellies for example could use limited range)
+ else if (Gear^.Layer <> 2) and (round(Y) + 50 > LAND_HEIGHT) then
+ Y:= Y - (1024 + 25);
Timer:= 0;
tdX:= 0;
tdY:= 0
@@ -112,8 +125,11 @@
Gear^.Y := LAND_HEIGHT - 1184 + LongInt(Gear^.Timer mod 8) + t;
-if round(Gear^.X) < cLeftScreenBorder then Gear^.X:= Gear^.X + cScreenSpace else
-if round(Gear^.X) > cRightScreenBorder then Gear^.X:= Gear^.X - cScreenSpace
+if round(Gear^.X) < cLeftScreenBorder then
+ Gear^.X:= Gear^.X + cScreenSpace
+else
+ if round(Gear^.X) > cRightScreenBorder then
+ Gear^.X:= Gear^.X - cScreenSpace
end;
////////////////////////////////////////////////////////////////////////////////
@@ -125,7 +141,8 @@
//Gear^.dY:= Gear^.dY + cGravityf;
if Gear^.FrameTicks <= Steps then
- if Gear^.Frame = 0 then DeleteVisualGear(Gear)
+ if Gear^.Frame = 0 then
+ DeleteVisualGear(Gear)
else
begin
dec(Gear^.Frame);
@@ -243,102 +260,108 @@
////////////////////////////////////////////////////////////////////////////////
procedure doStepBubble(Gear: PVisualGear; Steps: Longword);
begin
- Gear^.X:= Gear^.X + Gear^.dX * Steps;
- Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
- Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps;
+Gear^.X:= Gear^.X + Gear^.dX * Steps;
+Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
+Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps;
+Gear^.dX := Gear^.dX / (1.001 * Steps);
+Gear^.dY := Gear^.dY / (1.001 * Steps);
- Gear^.dX := Gear^.dX / (1.001 * Steps);
- Gear^.dY := Gear^.dY / (1.001 * Steps);
-
- if (Gear^.FrameTicks <= Steps) or (round(Gear^.Y) < cWaterLine) then
- DeleteVisualGear(Gear)
- else
- dec(Gear^.FrameTicks, Steps)
+if (Gear^.FrameTicks <= Steps) or (round(Gear^.Y) < cWaterLine) then
+ DeleteVisualGear(Gear)
+else
+ dec(Gear^.FrameTicks, Steps)
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepSteam(Gear: PVisualGear; Steps: Longword);
begin
- Gear^.X:= Gear^.X + (cWindSpeedf * 100 + Gear^.dX) * Steps;
- Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps;
+Gear^.X:= Gear^.X + (cWindSpeedf * 100 + Gear^.dX) * Steps;
+Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps;
- if Gear^.FrameTicks <= Steps then
- if Gear^.Frame = 0 then DeleteVisualGear(Gear)
- else
- begin
- if Random(2) = 0 then dec(Gear^.Frame);
- Gear^.FrameTicks:= cExplFrameTicks
- end
- else dec(Gear^.FrameTicks, Steps)
+if Gear^.FrameTicks <= Steps then
+ if Gear^.Frame = 0 then
+ DeleteVisualGear(Gear)
+ else
+ begin
+ if Random(2) = 0 then
+ dec(Gear^.Frame);
+ Gear^.FrameTicks:= cExplFrameTicks
+ end
+else dec(Gear^.FrameTicks, Steps)
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepAmmo(Gear: PVisualGear; Steps: Longword);
begin
- Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps;
+Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps;
- Gear^.scale:= Gear^.scale + 0.0025 * Steps;
- Gear^.alpha:= Gear^.alpha - 0.0015 * Steps;
+Gear^.scale:= Gear^.scale + 0.0025 * Steps;
+Gear^.alpha:= Gear^.alpha - 0.0015 * Steps;
- if Gear^.alpha < 0 then DeleteVisualGear(Gear)
+if Gear^.alpha < 0 then
+ DeleteVisualGear(Gear)
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepSmoke(Gear: PVisualGear; Steps: Longword);
begin
- Gear^.X:= Gear^.X + (cWindSpeedf + Gear^.dX) * Steps;
- Gear^.Y:= Gear^.Y - (cDrownSpeedf + Gear^.dY) * Steps;
+Gear^.X:= Gear^.X + (cWindSpeedf + Gear^.dX) * Steps;
+Gear^.Y:= Gear^.Y - (cDrownSpeedf + Gear^.dY) * Steps;
- Gear^.dX := Gear^.dX + (cWindSpeedf * 0.3 * Steps);
- //Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.995);
+Gear^.dX := Gear^.dX + (cWindSpeedf * 0.3 * Steps);
+//Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.995);
- if Gear^.FrameTicks <= Steps then
- if Gear^.Frame = 0 then DeleteVisualGear(Gear)
- else
- begin
- if Random(2) = 0 then dec(Gear^.Frame);
- Gear^.FrameTicks:= cExplFrameTicks
- end
- else dec(Gear^.FrameTicks, Steps)
+if Gear^.FrameTicks <= Steps then
+ if Gear^.Frame = 0 then
+ DeleteVisualGear(Gear)
+ else
+ begin
+ if Random(2) = 0 then
+ dec(Gear^.Frame);
+ Gear^.FrameTicks:= cExplFrameTicks
+ end
+ else dec(Gear^.FrameTicks, Steps)
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepDust(Gear: PVisualGear; Steps: Longword);
begin
- Gear^.X:= Gear^.X + (cWindSpeedf + (cWindSpeedf * 0.03 * Steps) + Gear^.dX) * Steps;
- Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps;
+Gear^.X:= Gear^.X + (cWindSpeedf + (cWindSpeedf * 0.03 * Steps) + Gear^.dX) * Steps;
+Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps;
- Gear^.dX := Gear^.dX - (Gear^.dX * 0.005 * Steps);
- Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.001 * Steps);
+Gear^.dX := Gear^.dX - (Gear^.dX * 0.005 * Steps);
+Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.001 * Steps);
- if Gear^.FrameTicks <= Steps then
- if Gear^.Frame = 0 then DeleteVisualGear(Gear)
- else
- begin
- dec(Gear^.Frame);
- Gear^.FrameTicks:= cExplFrameTicks
- end
- else dec(Gear^.FrameTicks, Steps)
+if Gear^.FrameTicks <= Steps then
+ if Gear^.Frame = 0 then
+ DeleteVisualGear(Gear)
+ else
+ begin
+ dec(Gear^.Frame);
+ Gear^.FrameTicks:= cExplFrameTicks
+ end
+ else dec(Gear^.FrameTicks, Steps)
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepSplash(Gear: PVisualGear; Steps: Longword);
begin
- if Gear^.FrameTicks <= Steps then
- DeleteVisualGear(Gear)
- else
- dec(Gear^.FrameTicks, Steps);
+if Gear^.FrameTicks <= Steps then
+ DeleteVisualGear(Gear)
+else
+ dec(Gear^.FrameTicks, Steps);
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepDroplet(Gear: PVisualGear; Steps: Longword);
begin
- Gear^.X:= Gear^.X + Gear^.dX * Steps;
+Gear^.X:= Gear^.X + Gear^.dX * Steps;
- Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
- Gear^.dY:= Gear^.dY + cGravityf * Steps;
+Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
+Gear^.dY:= Gear^.dY + cGravityf * Steps;
- if round(Gear^.Y) > cWaterLine then begin
+if round(Gear^.Y) > cWaterLine then
+ begin
DeleteVisualGear(Gear);
PlaySound(TSound(ord(sndDroplet1) + Random(3)));
end;
@@ -348,12 +371,14 @@
procedure doStepSmokeRing(Gear: PVisualGear; Steps: Longword);
begin
inc(Gear^.Timer, Steps);
-if Gear^.Timer >= Gear^.FrameTicks then DeleteVisualGear(Gear)
+if Gear^.Timer >= Gear^.FrameTicks then
+ DeleteVisualGear(Gear)
else
begin
Gear^.scale := 1.25 * (-power(2, -10 * Int(Gear^.Timer)/Gear^.FrameTicks) + 1) + 0.4;
Gear^.alpha := 1 - power(Gear^.Timer / 350, 4);
- if Gear^.alpha < 0 then Gear^.alpha:= 0;
+ if Gear^.alpha < 0 then
+ Gear^.alpha:= 0;
end;
end;
@@ -401,7 +426,8 @@
if (Gear^.Timer = 0) or (currsorter <> Gear) then
begin
- if currsorter = Gear then currsorter:= nil;
+ if currsorter = Gear then
+ currsorter:= nil;
DeleteVisualGear(Gear);
exit
end
@@ -477,7 +503,8 @@
Steps:= Steps; // avoid compiler hint
with Gear^.Hedgehog^ do
- if SpeechGear <> nil then SpeechGear^.Timer:= 0;
+ if SpeechGear <> nil then
+ SpeechGear^.Timer:= 0;
Gear^.Hedgehog^.SpeechGear:= Gear;
@@ -536,7 +563,8 @@
Gear^.Y:= Gear^.Y - Gear^.Tex^.h;
-if Steps > 1 then Gear^.doStep(Gear, Steps-1);
+if Steps > 1 then
+ Gear^.doStep(Gear, Steps-1);
end;
////////////////////////////////////////////////////////////////////////////////
@@ -546,10 +574,10 @@
if Gear^.Timer > 64 then
begin
if Gear^.State = 0 then
- begin
- DeleteVisualGear(Gear);
- exit;
- end;
+ begin
+ DeleteVisualGear(Gear);
+ exit;
+ end;
dec(Gear^.State, Gear^.Timer div 65);
Gear^.Timer:= Gear^.Timer mod 65;
end;
@@ -565,7 +593,8 @@
begin
inc(Gear^.State, Gear^.Timer div 76);
Gear^.Timer:= Gear^.Timer mod 76;
- if Gear^.State > 5 then DeleteVisualGear(Gear);
+ if Gear^.State > 5 then
+ DeleteVisualGear(Gear);
end;
end;
@@ -588,7 +617,8 @@
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart);
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart2);
Gear^.doStep:= @doStepExplosionWork;
-if Steps > 1 then Gear^.doStep(Gear, Steps-1);
+if Steps > 1 then
+ Gear^.doStep(Gear, Steps-1);
end;
@@ -604,7 +634,8 @@
ShakeCamera(maxMovement);
end;
-if Gear^.Timer > 250 then DeleteVisualGear(Gear);
+if Gear^.Timer > 250 then
+ DeleteVisualGear(Gear);
end;
procedure doStepBigExplosion(Gear: PVisualGear; Steps: Longword);
@@ -627,10 +658,13 @@
inc(vg^.FrameTicks, vg^.FrameTicks)
end
end;
-for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart);
-for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart2);
+for i:= 0 to 15 do
+ AddVisualGear(gX, gY, vgtExplPart);
+for i:= 0 to 15 do
+ AddVisualGear(gX, gY, vgtExplPart2);
Gear^.doStep:= @doStepBigExplosionWork;
-if Steps > 1 then Gear^.doStep(Gear, Steps-1);
+if Steps > 1 then
+ Gear^.doStep(Gear, Steps-1);
performRumble();
end;
@@ -653,10 +687,10 @@
////////////////////////////////////////////////////////////////////////////////
procedure doStepBulletHit(Gear: PVisualGear; Steps: Longword);
begin
- if Gear^.FrameTicks <= Steps then
- DeleteVisualGear(Gear)
- else
- dec(Gear^.FrameTicks, Steps);
+if Gear^.FrameTicks <= Steps then
+ DeleteVisualGear(Gear)
+else
+ dec(Gear^.FrameTicks, Steps);
end;
////////////////////////////////////////////////////////////////////////////////
@@ -672,12 +706,18 @@
if (FrameTicks mod Frame) = 0 then
begin
tmp:= Gear^.Tint and $FF;
- if tdY >= 0 then inc(tmp)
- else dec(tmp);
- if tmp < round(dX) then tdY:= 1;
- if tmp > round(dY) then tdY:= -1;
- if tmp > 255 then tmp := 255;
- if tmp < 0 then tmp := 0;
+ if tdY >= 0 then
+ inc(tmp)
+ else
+ dec(tmp);
+ if tmp < round(dX) then
+ tdY:= 1;
+ if tmp > round(dY) then
+ tdY:= -1;
+ if tmp > 255 then
+ tmp := 255;
+ if tmp < 0 then
+ tmp := 0;
Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or Longword(tmp)
end
end
@@ -686,13 +726,15 @@
////////////////////////////////////////////////////////////////////////////////
procedure doStepSmoothWindBar(Gear: PVisualGear; Steps: Longword);
begin
- inc(Gear^.Timer, Steps);
+inc(Gear^.Timer, Steps);
while Gear^.Timer >= 10 do
begin
dec(Gear^.Timer, 10);
- if WindBarWidth < Gear^.Tag then inc(WindBarWidth)
- else if WindBarWidth > Gear^.Tag then dec(WindBarWidth);
+ if WindBarWidth < Gear^.Tag then
+ inc(WindBarWidth)
+ else if WindBarWidth > Gear^.Tag then
+ dec(WindBarWidth);
end;
if WindBarWidth = Gear^.Tag then