Testing explosion particles implementation
authorunc0rr
Fri, 04 Jul 2008 14:40:52 +0000
changeset 1045 ea195268734f
parent 1044 f759aae1062f
child 1046 c22d833c3ae2
Testing explosion particles implementation
hedgewars.kdevelop
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uStore.pas
hedgewars/uVisualGears.pas
hedgewars/uWorld.pas
share/hedgewars/Data/Graphics/ExplPart.png
--- a/hedgewars.kdevelop	Tue Jul 01 22:26:36 2008 +0000
+++ b/hedgewars.kdevelop	Fri Jul 04 14:40:52 2008 +0000
@@ -39,83 +39,17 @@
       <autokdesu>false</autokdesu>
     </run>
     <filetypes>
-      <filetype>*.java</filetype>
       <filetype>*.h</filetype>
-      <filetype>*.H</filetype>
-      <filetype>*.hh</filetype>
-      <filetype>*.hxx</filetype>
-      <filetype>*.hpp</filetype>
       <filetype>*.c</filetype>
-      <filetype>*.C</filetype>
       <filetype>*.cc</filetype>
       <filetype>*.cpp</filetype>
       <filetype>*.c++</filetype>
-      <filetype>*.cxx</filetype>
-      <filetype>Makefile</filetype>
       <filetype>CMakeLists.txt</filetype>
       <filetype>*.pas</filetype>
       <filetype>*.inc</filetype>
       <filetype>*.dpr</filetype>
     </filetypes>
-    <blacklist>
-      <path>QTfrontend/moc_SDLs.cxx</path>
-      <path>QTfrontend/moc_SquareLabel.cxx</path>
-      <path>QTfrontend/moc_about.cxx</path>
-      <path>QTfrontend/moc_chatwidget.cxx</path>
-      <path>QTfrontend/moc_fpsedit.cxx</path>
-      <path>QTfrontend/moc_frameTeam.cxx</path>
-      <path>QTfrontend/moc_game.cxx</path>
-      <path>QTfrontend/moc_gamecfgwidget.cxx</path>
-      <path>QTfrontend/moc_gameuiconfig.cxx</path>
-      <path>QTfrontend/moc_hedgehogerWidget.cxx</path>
-      <path>QTfrontend/moc_hwform.cxx</path>
-      <path>QTfrontend/moc_hwmap.cxx</path>
-      <path>QTfrontend/moc_input_ip.cxx</path>
-      <path>QTfrontend/moc_itemNum.cxx</path>
-      <path>QTfrontend/moc_mapContainer.cxx</path>
-      <path>QTfrontend/moc_netconnectedclient.cxx</path>
-      <path>QTfrontend/moc_netregister.cxx</path>
-      <path>QTfrontend/moc_netserver.cxx</path>
-      <path>QTfrontend/moc_netserverslist.cxx</path>
-      <path>QTfrontend/moc_netudpserver.cxx</path>
-      <path>QTfrontend/moc_netudpwidget.cxx</path>
-      <path>QTfrontend/moc_netwwwserver.cxx</path>
-      <path>QTfrontend/moc_netwwwwidget.cxx</path>
-      <path>QTfrontend/moc_newnetclient.cxx</path>
-      <path>QTfrontend/moc_pages.cxx</path>
-      <path>QTfrontend/moc_playrecordpage.cxx</path>
-      <path>QTfrontend/moc_proto.cxx</path>
-      <path>QTfrontend/moc_selectWeapon.cxx</path>
-      <path>QTfrontend/moc_tcpBase.cxx</path>
-      <path>QTfrontend/moc_teamselect.cxx</path>
-      <path>QTfrontend/moc_teamselhelper.cxx</path>
-      <path>QTfrontend/moc_vertScrollArea.cxx</path>
-      <path>QTfrontend/moc_weaponItem.cxx</path>
-      <path>bin/Makefile</path>
-      <path>bin/checkstack.pas</path>
-      <path>CMakeFiles</path>
-      <path>CMakeFiles/CompilerIdC</path>
-      <path>CMakeFiles/CompilerIdC/CMakeCCompilerId.c</path>
-      <path>CMakeFiles/CompilerIdCXX</path>
-      <path>CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp</path>
-      <path>Makefile</path>
-      <path>QTfrontend/qrc_hedgewars.cxx</path>
-      <path>misc</path>
-      <path>misc/fbsd-port</path>
-      <path>misc/fbsd-port/Makefile</path>
-      <path>share/Makefile</path>
-      <path>share/hedgewars/Data/Fonts/Makefile</path>
-      <path>share/hedgewars/Data/Forts/Makefile</path>
-      <path>share/hedgewars/Data/Graphics/Makefile</path>
-      <path>share/hedgewars/Data/Locale/Makefile</path>
-      <path>share/hedgewars/Data/Makefile</path>
-      <path>share/hedgewars/Data/Maps/Makefile</path>
-      <path>share/hedgewars/Data/Music/Makefile</path>
-      <path>share/hedgewars/Data/Sounds/Makefile</path>
-      <path>share/hedgewars/Data/Themes/Makefile</path>
-      <path>share/hedgewars/Data/Trainings/Makefile</path>
-      <path>share/hedgewars/Makefile</path>
-    </blacklist>
+    <blacklist/>
     <general>
       <activedir/>
     </general>
--- a/hedgewars/GSHandlers.inc	Tue Jul 01 22:26:36 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Fri Jul 04 14:40:52 2008 +0000
@@ -782,7 +782,7 @@
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
-procedure doStepExplosion(Gear: PGear);
+procedure doStepExplosionWork(Gear: PGear);
 begin
 inc(Gear^.Timer);
 if Gear^.Timer > 75 then
@@ -793,6 +793,13 @@
    end;
 end;
 
+procedure doStepExplosion(Gear: PGear);
+var i: LongWord;
+begin
+for i:= 0 to 15 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart);
+Gear^.doStep:= @doStepExplosionWork
+end;
+
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepMine(Gear: PGear);
 begin
--- a/hedgewars/uConsts.pas	Tue Jul 01 22:26:36 2008 +0000
+++ b/hedgewars/uConsts.pas	Fri Jul 04 14:40:52 2008 +0000
@@ -46,7 +46,7 @@
                    sprHandBlowTorch, sprBlowTorch, sprTeleport, sprHHDeath,
                    sprShotgun, sprDEagle, sprHHIdle, sprMortar, sprTurnsLeft,
                    sprHat, sprKamikaze, sprWhip, sprKowtow, sprSad, sprWave,
-                   sprHurrah, sprLemonade);
+                   sprHurrah, sprLemonade, sprExplPart);
 
      TGearType  = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
                    gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope,
@@ -411,7 +411,9 @@
                      (FileName:     'Hurrah'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width:  32; Height: 32; saveSurf: false),// sprHurrah
                      (FileName:'ILoveLemonade';Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width: 128; Height: 32; saveSurf: false) // sprLemonade
+                      Width: 128; Height: 32; saveSurf: false),// sprLemonade
+                     (FileName:   'ExplPart'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
+                      Width:  32; Height: 32; saveSurf: false) // sprExplPart
                      );
 
 	Wavez: array [TWave] of record
--- a/hedgewars/uGears.pas	Tue Jul 01 22:26:36 2008 +0000
+++ b/hedgewars/uGears.pas	Fri Jul 04 14:40:52 2008 +0000
@@ -72,7 +72,7 @@
 implementation
 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
      uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, GL,
-     uStats;
+     uStats, uVisualGears;
 
 const MAXROPEPOINTS = 300;
 var RopePoints: record
--- a/hedgewars/uStore.pas	Tue Jul 01 22:26:36 2008 +0000
+++ b/hedgewars/uStore.pas	Fri Jul 04 14:40:52 2008 +0000
@@ -617,6 +617,7 @@
    ProgrTex:= Surface2Tex(texsurf);
    SDL_FreeSurface(texsurf)
    end;
+
 glClear(GL_COLOR_BUFFER_BIT);
 glEnable(GL_TEXTURE_2D);
 r.x:= 0;
--- a/hedgewars/uVisualGears.pas	Tue Jul 01 22:26:36 2008 +0000
+++ b/hedgewars/uVisualGears.pas	Fri Jul 04 14:40:52 2008 +0000
@@ -40,7 +40,7 @@
 
 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
 procedure ProcessVisualGears(Steps: Longword);
-procedure DrawVisualGears();
+procedure DrawVisualGears(Layer: LongWord);
 procedure DeleteVisualGear(Gear: PVisualGear);
 procedure AddClouds;
 
@@ -50,6 +50,7 @@
 
 implementation
 uses uWorld, uMisc, uStore;
+const cExplFrameTicks = 80;
 
 // ==================================================================
 procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
@@ -93,8 +94,14 @@
 Gear^.Y:= Gear^.Y + Gear^.dY;
 Gear^.dY:= Gear^.dY + cGravity;
 
-dec(Gear^.FrameTicks);
-if Gear^.FrameTicks = 0 then DeleteVisualGear(Gear)
+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;
 
 // ==================================================================
@@ -107,6 +114,8 @@
 
 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
 var Result: PVisualGear;
+	t: Longword;
+	sp: hwFloat;
 begin
 New(Result);
 FillChar(Result^, sizeof(TVisualGear), 0);
@@ -138,11 +147,14 @@
                end;
   vgtExplPart: with Result^ do
                begin
+               t:= random(1024);
+               sp:= _0_001 * (random(700) + 150);
+               dx:= AngleSin(t) * sp;
                dx.isNegative:= random(2) = 0;
-               dx.QWordValue:= random(300000) + 1000000;
+               dy:= AngleCos(t) * sp;
                dy.isNegative:= random(2) = 0;
-               dy.QWordValue:= random(300000) + 1000000;
-               FrameTicks:= 700
+               Frame:= 7 - random(3);
+               FrameTicks:= cExplFrameTicks
                end;
      end;
 
@@ -179,22 +191,30 @@
       end
 end;
 
-procedure DrawVisualGears();
+procedure DrawVisualGears(Layer: LongWord);
 var Gear: PVisualGear;
 begin
 Gear:= VisualGearsList;
-while Gear <> nil do
-      begin
-      case Gear^.Kind of
-           vgtFlake: if vobVelocity = 0 then
-                        DrawSprite(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame)
-                     else
-                        DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
-
-           vgtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame);
-              end;
-      Gear:= Gear^.NextGear
-      end;
+case Layer of
+	0: while Gear <> nil do
+		begin
+		case Gear^.Kind of
+			vgtFlake: if vobVelocity = 0 then
+						DrawSprite(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame)
+					else
+						DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
+			vgtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame);
+			end;
+		Gear:= Gear^.NextGear
+		end;
+	1: while Gear <> nil do
+		begin
+		case Gear^.Kind of
+			vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
+			end;
+		Gear:= Gear^.NextGear
+		end
+	end
 end;
 
 procedure AddClouds;
--- a/hedgewars/uWorld.pas	Tue Jul 01 22:26:36 2008 +0000
+++ b/hedgewars/uWorld.pas	Fri Jul 04 14:40:52 2008 +0000
@@ -189,7 +189,7 @@
 DrawRepeated(sprSky, WorldDx * 3 div 8);
 DrawRepeated(sprHorizont, WorldDx * 3 div 5);
 
-DrawVisualGears;
+DrawVisualGears(0);
 
 // Waves
 {$WARNINGS OFF}
@@ -220,6 +220,8 @@
 
 DrawGears;
 
+DrawVisualGears(1);
+
 // Waves
 {$WARNINGS OFF}
 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6) +  64) and $FF), cWaterLine + WorldDy - 32, 0);
Binary file share/hedgewars/Data/Graphics/ExplPart.png has changed