add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
authornemo
Thu, 03 Oct 2013 12:10:30 -0400
changeset 9485 3dee8a3b0406
parent 9483 14ad1ac00ac9
child 9487 fbe203c1d11e
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsUtils.pas
hedgewars/uWorld.pas
--- a/hedgewars/uGearsHandlersMess.pas	Mon Sep 30 22:46:48 2013 +0400
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Oct 03 12:10:30 2013 -0400
@@ -1056,6 +1056,7 @@
     repeat
         Gear^.X := Gear^.X + Gear^.dX;
         Gear^.Y := Gear^.Y + Gear^.dY;
+        WorldWrap(Gear);
         CheckCollision(Gear);
         if (Gear^.State and gstCollision) <> 0 then
             begin
@@ -1121,16 +1122,9 @@
 procedure doStepBulletWork(Gear: PGear);
 var
     i, x, y: LongWord;
-    oX, oY: hwFloat;
+    oX, oY, tX, tY, cX, cY: hwFloat;
     VGear: PVisualGear;
 begin
-    if WorldWrap(Gear) then
-        begin
-        SpawnBulletTrail(Gear);
-        inc(Gear^.PortalCounter);
-        Gear^.Elasticity:= Gear^.X;
-        Gear^.Friction:= Gear^.Y
-        end;
     AllInactive := false;
     inc(Gear^.Timer);
     i := 80;
@@ -1139,6 +1133,22 @@
     repeat
         Gear^.X := Gear^.X + Gear^.dX;
         Gear^.Y := Gear^.Y + Gear^.dY;
+        tX:= Gear^.X;
+        tY:= Gear^.Y;
+        if WorldWrap(Gear) then
+            begin
+            cX:= Gear^.X;
+            cY:= Gear^.Y;
+            Gear^.X:= tX;
+            Gear^.Y:= tY;
+            SpawnBulletTrail(Gear);
+            Gear^.X:= cX;
+            Gear^.Y:= cY;
+            inc(Gear^.PortalCounter);
+            Gear^.Elasticity:= Gear^.X;
+            Gear^.Friction:= Gear^.Y;
+            SpawnBulletTrail(Gear);
+            end;
         x := hwRound(Gear^.X);
         y := hwRound(Gear^.Y);
 
--- a/hedgewars/uGearsUtils.pas	Mon Sep 30 22:46:48 2013 +0400
+++ b/hedgewars/uGearsUtils.pas	Thu Oct 03 12:10:30 2013 -0400
@@ -1224,26 +1224,26 @@
 // for playing around since it isn't hooked up yet
 //WorldEdge:= weBounce;
 if WorldEdge = weNone then exit(false);
-if (hwRound(Gear^.X)-Gear^.Radius < (leftX-100)) or
-   (hwRound(Gear^.X)+Gear^.Radius > (rightX+100)) then
+if (hwRound(Gear^.X)-Gear^.Radius < leftX) or
+   (hwRound(Gear^.X)+Gear^.Radius > rightX) then
     begin
     if WorldEdge = weWrap then
         begin
-        if (hwRound(Gear^.X)-Gear^.Radius < leftX-100) then
-             Gear^.X:= int2hwfloat(rightX-Gear^.Radius+100)
-        else Gear^.X:= int2hwfloat(leftX+Gear^.Radius-100)
+        if (hwRound(Gear^.X)-Gear^.Radius < leftX) then
+             Gear^.X:= int2hwfloat(rightX-Gear^.Radius)
+        else Gear^.X:= int2hwfloat(leftX+Gear^.Radius)
         end
     else if WorldEdge = weBounce then
         begin
         if (hwRound(Gear^.X)-Gear^.Radius < leftX) then
             begin
             Gear^.dX.isNegative:= false;
-            Gear^.X:= int2hwfloat(leftX+Gear^.Radius-100)
+            Gear^.X:= int2hwfloat(leftX+Gear^.Radius)
             end
         else 
             begin
             Gear^.dX.isNegative:= true;
-            Gear^.X:= int2hwfloat(rightX-Gear^.Radius+100)
+            Gear^.X:= int2hwfloat(rightX-Gear^.Radius)
             end
         end
     else if WorldEdge = weSea then
--- a/hedgewars/uWorld.pas	Mon Sep 30 22:46:48 2013 +0400
+++ b/hedgewars/uWorld.pas	Thu Oct 03 12:10:30 2013 -0400
@@ -1258,22 +1258,22 @@
     glTranslatef(WorldDx, WorldDy, 0);
     glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WorldFade[0]);
 
-    VertexBuffer[0].X:= leftX-120;
+    VertexBuffer[0].X:= leftX-20;
     VertexBuffer[0].Y:= -3000;
-    VertexBuffer[1].X:= leftX-120;
+    VertexBuffer[1].X:= leftX-20;
     VertexBuffer[1].Y:= cWaterLine+cVisibleWater;
-    VertexBuffer[2].X:= leftX-70;
+    VertexBuffer[2].X:= leftX+30;
     VertexBuffer[2].Y:= cWaterLine+cVisibleWater;
-    VertexBuffer[3].X:= leftX-70;
+    VertexBuffer[3].X:= leftX+30;
     VertexBuffer[3].Y:= -3000;
 
     glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
     glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
 
-    VertexBuffer[0].X:= rightX+120;
-    VertexBuffer[1].X:= rightX+120;
-    VertexBuffer[2].X:= rightX+70;
-    VertexBuffer[3].X:= rightX+70;
+    VertexBuffer[0].X:= rightX+20;
+    VertexBuffer[1].X:= rightX+20;
+    VertexBuffer[2].X:= rightX-30;
+    VertexBuffer[3].X:= rightX-30;
 
     glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
     glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
@@ -1282,16 +1282,16 @@
 
     VertexBuffer[0].X:= -5000;
     VertexBuffer[1].X:= -5000;
-    VertexBuffer[2].X:= leftX-120;
-    VertexBuffer[3].X:= leftX-120;
+    VertexBuffer[2].X:= leftX-20;
+    VertexBuffer[3].X:= leftX-20;
 
     glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
     glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
 
     VertexBuffer[0].X:= rightX+5000;
     VertexBuffer[1].X:= rightX+5000;
-    VertexBuffer[2].X:= rightX+120;
-    VertexBuffer[3].X:= rightX+120;
+    VertexBuffer[2].X:= rightX+20;
+    VertexBuffer[3].X:= rightX+20;
 
     glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
     glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
@@ -1303,8 +1303,8 @@
     glColor4ub($FF, $FF, $FF, $FF); // must not be Tint() as color array seems to stay active and color reset is required
     glEnable(GL_TEXTURE_2D);
 
-    DrawLine(leftX-100, -3000, leftX-100, cWaterLine+cVisibleWater, 3.0, $FF, $00, $FF, $FF);
-    DrawLine(rightX+100, -3000, rightX+100, cWaterLine+cVisibleWater, 3.0, $FF, $00, $FF, $FF);
+    DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 3.0, $FF, $00, $FF, $FF);
+    DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 3.0, $FF, $00, $FF, $FF);
     end;
 
 // this scale is used to keep the various widgets at the same dimension at all zoom levels