Better ?? implementation of explosion
authorunc0rr
Fri, 04 Jul 2008 19:25:00 +0000
changeset 1046 c22d833c3ae2
parent 1045 ea195268734f
child 1047 ca7078116c0c
Better ?? implementation of explosion
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uVisualGears.pas
share/hedgewars/Data/Graphics/ExplPart.png
--- a/hedgewars/GSHandlers.inc	Fri Jul 04 14:40:52 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Fri Jul 04 19:25:00 2008 +0000
@@ -796,6 +796,7 @@
 procedure doStepExplosion(Gear: PGear);
 var i: LongWord;
 begin
+for i:= 0 to 15 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFire);
 for i:= 0 to 15 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart);
 Gear^.doStep:= @doStepExplosionWork
 end;
--- a/hedgewars/uConsts.pas	Fri Jul 04 14:40:52 2008 +0000
+++ b/hedgewars/uConsts.pas	Fri Jul 04 19:25:00 2008 +0000
@@ -57,7 +57,7 @@
                    gtTeleport, gtSmallDamage, gtSwitcher, gtTarget, gtMortar,
                    gtWhip, gtKamikaze);
 
-     TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart);
+     TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtFire);
 
      TGearsType = set of TGearType;
 
--- a/hedgewars/uVisualGears.pas	Fri Jul 04 14:40:52 2008 +0000
+++ b/hedgewars/uVisualGears.pas	Fri Jul 04 19:25:00 2008 +0000
@@ -89,10 +89,10 @@
 
 procedure doStepExpl(Gear: PVisualGear; Steps: Longword);
 begin
-Gear^.X:= Gear^.X + Gear^.dX;
+Gear^.X:= Gear^.X + Gear^.dX * Steps;
 
-Gear^.Y:= Gear^.Y + Gear^.dY;
-Gear^.dY:= Gear^.dY + cGravity;
+Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
+//Gear^.dY:= Gear^.dY + cGravity;
 
 if Gear^.FrameTicks <= Steps then
 	if Gear^.Frame = 0 then DeleteVisualGear(Gear)
@@ -104,12 +104,26 @@
 	else dec(Gear^.FrameTicks, Steps)
 end;
 
+procedure doStepFire(Gear: PVisualGear; Steps: Longword);
+begin
+Gear^.X:= Gear^.X + Gear^.dX * Steps;
+
+Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravity * (Steps * Steps);
+Gear^.dY:= Gear^.dY + cGravity * Steps;
+
+if Gear^.FrameTicks <= Steps then
+	DeleteVisualGear(Gear)
+else
+	dec(Gear^.FrameTicks, Steps)
+end;
+
 // ==================================================================
 const doStepHandlers: array[TVisualGearType] of TVGearStepProcedure =
                         (
                           @doStepFlake,
                           @doStepCloud,
-                          @doStepExpl
+                          @doStepExpl,
+                          @doStepFire
                         );
 
 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
@@ -148,7 +162,7 @@
   vgtExplPart: with Result^ do
                begin
                t:= random(1024);
-               sp:= _0_001 * (random(700) + 150);
+               sp:= _0_001 * (random(80) + 85);
                dx:= AngleSin(t) * sp;
                dx.isNegative:= random(2) = 0;
                dy:= AngleCos(t) * sp;
@@ -156,6 +170,17 @@
                Frame:= 7 - random(3);
                FrameTicks:= cExplFrameTicks
                end;
+      vgtFire: with Result^ do
+               begin
+               t:= random(1024);
+               sp:= _0_001 * (random(85) + 95);
+               dx:= AngleSin(t) * sp;
+               dx.isNegative:= random(2) = 0;
+               dy:= AngleCos(t) * sp;
+               dy.isNegative:= random(2) = 0;
+               FrameTicks:= 400 + random(200);
+               Frame:= random(8)
+               end;
      end;
 
 if VisualGearsList <> nil then
@@ -211,6 +236,7 @@
 		begin
 		case Gear^.Kind of
 			vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
+			vgtFire: DrawSprite(sprFlame, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8);
 			end;
 		Gear:= Gear^.NextGear
 		end
Binary file share/hedgewars/Data/Graphics/ExplPart.png has changed