hedgewars/GSHandlers.inc
changeset 3388 ab9352a4ddcc
parent 3384 7eb4707d43f0
child 3391 77161719ec3c
equal deleted inserted replaced
3387:733f4001b8b9 3388:ab9352a4ddcc
  3050 2) From then on, if doStepPortal is called and a gear of a radius less than or equal to the portal is within X pixels of the portal (we could also check on moving toward the portal I guess, depends how accurate this needs to be) the portal will then locate the first other portal of the opposite type (there should only be one other one), and move that gear's X/Y to that other portal's location, and modify dX/dY to be relative to that other portal's orientation relative to this portal's orientation.  This might require some tweaking with offsets of a few pixels to avoid getting gears stuck in land.
  3050 2) From then on, if doStepPortal is called and a gear of a radius less than or equal to the portal is within X pixels of the portal (we could also check on moving toward the portal I guess, depends how accurate this needs to be) the portal will then locate the first other portal of the opposite type (there should only be one other one), and move that gear's X/Y to that other portal's location, and modify dX/dY to be relative to that other portal's orientation relative to this portal's orientation.  This might require some tweaking with offsets of a few pixels to avoid getting gears stuck in land.
  3051 
  3051 
  3052 3) At end of turn, all gtPortal will be deleted.
  3052 3) At end of turn, all gtPortal will be deleted.
  3053 
  3053 
  3054 *)
  3054 *)
  3055 end;
       
  3056 procedure doStepPortalGun(Gear: PGear);
       
  3057 begin
       
  3058 (*
  3055 (*
  3059 Ok. Here's where I plan to go with this.
  3056 Ok. Here's where I plan to go with this.
  3060 1) Restrict portal gun to X shots.
  3057 1) Restrict portal gun to X shots.
  3061 2) If on first shot, delete all existing gtPortal
  3058 2) If on first shot, delete all existing gtPortal
  3062 3) On any other shot, delete any existing portals of type X%2, and spawn a new portal of type X%2 oriented at angle 180° from the portal gun.  It might possibly be worth linking portals with a Gear reference, to save time on scanning through the Gear list every time we need a portal.
  3059 3) On any other shot, delete any existing portals of type X%2, and spawn a new portal of type X%2 oriented at angle 180° from the portal gun.  It might possibly be worth linking portals with a Gear reference, to save time on scanning through the Gear list every time we need a portal.
  3063 *)
  3060 *)
       
  3061 end;
       
  3062 
       
  3063 procedure doStepMovingPortal(Gear: PGear);
       
  3064 var i, x, y: LongWord;
       
  3065     oX, oY: hwFloat;
       
  3066 begin
       
  3067 oX:= Gear^.X;
       
  3068 oY:= Gear^.Y;
       
  3069 Gear^.X:= Gear^.X + Gear^.dX;
       
  3070 Gear^.Y:= Gear^.Y + Gear^.dY;
       
  3071 x:= hwRound(Gear^.X);
       
  3072 y:= hwRound(Gear^.Y);
       
  3073 (* 
       
  3074 Potential issue, portals embedded in land?
       
  3075 Also, will need checks on how well portal is placed
       
  3076 Thought is possibly doing it based on midpoint and two ends, so a bit of rough terrain is still permitted, but not curves.
       
  3077 *)
       
  3078 if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] <> 0) then
       
  3079     begin
       
  3080     inc(Gear^.Tag);
       
  3081     Gear^.doStep:= @doStepPortal;
       
  3082     AfterAttack
       
  3083     end
       
  3084 // How laser checks for infinite
       
  3085 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
       
  3086     begin
       
  3087     DeleteGear(Gear);
       
  3088     AfterAttack
       
  3089     end;
  3064 end;
  3090 end;
  3065 
  3091 
  3066 procedure doStepPiano(Gear: PGear);
  3092 procedure doStepPiano(Gear: PGear);
  3067 var r0, r1: LongInt;
  3093 var r0, r1: LongInt;
  3068 begin
  3094 begin