hedgewars/GSHandlers.inc
changeset 3388 ab9352a4ddcc
parent 3384 7eb4707d43f0
child 3391 77161719ec3c
--- a/hedgewars/GSHandlers.inc	Sat May 01 17:29:48 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Sat May 01 18:44:25 2010 +0000
@@ -3052,9 +3052,6 @@
 3) At end of turn, all gtPortal will be deleted.
 
 *)
-end;
-procedure doStepPortalGun(Gear: PGear);
-begin
 (*
 Ok. Here's where I plan to go with this.
 1) Restrict portal gun to X shots.
@@ -3063,6 +3060,35 @@
 *)
 end;
 
+procedure doStepMovingPortal(Gear: PGear);
+var i, x, y: LongWord;
+    oX, oY: hwFloat;
+begin
+oX:= Gear^.X;
+oY:= Gear^.Y;
+Gear^.X:= Gear^.X + Gear^.dX;
+Gear^.Y:= Gear^.Y + Gear^.dY;
+x:= hwRound(Gear^.X);
+y:= hwRound(Gear^.Y);
+(* 
+Potential issue, portals embedded in land?
+Also, will need checks on how well portal is placed
+Thought is possibly doing it based on midpoint and two ends, so a bit of rough terrain is still permitted, but not curves.
+*)
+if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] <> 0) then
+    begin
+    inc(Gear^.Tag);
+    Gear^.doStep:= @doStepPortal;
+    AfterAttack
+    end
+// How laser checks for infinite
+else if (y > LAND_HEIGHT + LAND_WIDTH div 4) or (y < - LAND_WIDTH div 4) or (x > LAND_WIDTH + LAND_WIDTH div 4) or (x < - LAND_WIDTH div 4) then
+    begin
+    DeleteGear(Gear);
+    AfterAttack
+    end;
+end;
+
 procedure doStepPiano(Gear: PGear);
 var r0, r1: LongInt;
 begin