Add a few comments for rubber duck
authorWuzzy <almikes@aol.com>
Thu, 12 May 2016 19:45:26 +0200
changeset 12207 fb2dea5c98f1
parent 12206 2c0811bbc1d9
child 12208 668ee6e388bd
Add a few comments for rubber duck
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
--- a/hedgewars/uGearsHandlersMess.pas	Thu May 12 19:33:30 2016 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Thu May 12 19:45:26 2016 +0200
@@ -4396,6 +4396,7 @@
                 continue;
 
         if iterator^.Kind = gtDuck then
+            // Make duck go into “falling” mode again
             iterator^.Pos:= 0;
 
         isbullet:= (iterator^.Kind in [gtShotgunShot, gtDEagleShot, gtSniperRifleShot, gtSineGunShot]);
@@ -6388,11 +6389,11 @@
         Gear^.Y:= Gear^.Y + Gear^.dY;
         end;
 
-    // Mirrored duck
-    // Pos 1 or 2: Duck is on water (not Sea world edge)
+    // Handle speed
     if Gear^.Pos = 1 then
         Gear^.dX:= cWindSpeed * Gear^.Damage
     else if Gear^.Pos = 2 then
+        // Mirrored duck (after bounce edge bounce)
         Gear^.dX:= -cWindSpeed * Gear^.Damage
     else if Gear^.Pos = 3 then
         Gear^.dY:= cWindSpeed * Gear^.Damage
@@ -6431,8 +6432,8 @@
     if Gear^.Pos <> 0 then
         // Manual collision check required because we don't use onStepFallingGear in this case
         CheckCollision(Gear);
-    // Explode duck
     if (Gear^.Timer = 0) or ((Gear^.State and gstCollision) <> 0) then
+        // Explode duck
         begin
         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound);
         PlaySound(sndDuckDie);
--- a/hedgewars/uGearsList.pas	Thu May 12 19:33:30 2016 +0200
+++ b/hedgewars/uGearsList.pas	Thu May 12 19:45:26 2016 +0200
@@ -720,10 +720,12 @@
                 gear^.Radius:= 8;
                 end;
         gtDuck: begin
-                gear^.Pos:= 0;               // 0: falling/in air, 1-4: on water
+                gear^.Pos:= 0;               // 0: in air, 1-4: on water,
+                                             // 1: bottom, 2: bottom (mirrored),
+                                             // 3: left Sea edge, 4: right Sea edge
                 gear^.Tag:= 1;               // 1: facing right, -1: facing left
                 if gear^.Timer = 0 then      
-                    gear^.Timer:= 15000;      // Explosion timer to avoid duck existing forever
+                    gear^.Timer:= 15000;     // Explosion timer to avoid duck existing forever
                 gear^.Radius:= 9;            // Collision radius (with landscape)
                 gear^.Karma:= 24;            // Distance from water when swimming
                 gear^.Damage:= 500;          // Speed factor when swimming on water (multiplied with wind speed)