3040 end; |
3038 end; |
3041 end; |
3039 end; |
3042 |
3040 |
3043 procedure doStepPortal(Gear: PGear); |
3041 procedure doStepPortal(Gear: PGear); |
3044 begin |
3042 begin |
|
3043 if Gear^.IntersectGear <> nil then |
|
3044 begin |
|
3045 // do portal stuff |
|
3046 end |
|
3047 |
3045 (* |
3048 (* |
3046 A portal will have a few things it does. |
|
3047 1) At first, it will move through the air until it collides with a surface. Once it does, it will stop. At this point we might try a check to verify there is enough terrain for it to be spawned against, and delete. Or we could just let it kinda stick out for now. |
|
3048 |
3049 |
3049 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. |
3050 |
3051 |
3051 3) At end of turn, all gtPortal will be deleted. |
|
3052 |
|
3053 *) |
3052 *) |
3054 (* |
|
3055 Ok. Here's where I plan to go with this. |
|
3056 1) Restrict portal gun to X shots. |
|
3057 2) If on first shot, delete all existing gtPortal |
|
3058 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 *) |
|
3060 end; |
3053 end; |
3061 |
3054 |
3062 procedure doStepMovingPortal(Gear: PGear); |
3055 procedure doStepMovingPortal(Gear: PGear); |
3063 var i, x, y: LongInt; |
3056 var x, y: LongInt;//, tx, ty, bx, by, tangle: LongInt; |
3064 oX, oY: hwFloat; |
3057 begin |
3065 begin |
|
3066 oX:= Gear^.X; |
|
3067 oY:= Gear^.Y; |
|
3068 Gear^.X:= Gear^.X + Gear^.dX; |
3058 Gear^.X:= Gear^.X + Gear^.dX; |
3069 Gear^.Y:= Gear^.Y + Gear^.dY; |
3059 Gear^.Y:= Gear^.Y + Gear^.dY; |
3070 x:= hwRound(Gear^.X); |
3060 x:= hwRound(Gear^.X); |
3071 y:= hwRound(Gear^.Y); |
3061 y:= hwRound(Gear^.Y); |
|
3062 |
|
3063 if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and ((Land[y, x] and $FF00) <> 0) then |
|
3064 begin |
3072 (* |
3065 (* |
3073 Potential issue, portals embedded in land? |
3066 This is not quite doing what I want, but basically hoping to avoid portals just sitting out in midair |
3074 Also, will need checks on how well portal is placed |
3067 Works ok for right angles, aaaand that's about it. |
3075 Thought is possibly doing it based on midpoint and two ends, so a bit of rough terrain is still permitted, but not curves. |
3068 The opposite approach could be taken, we could determine the angle of the land using sheepluva's code and snap the Angle/DirAngle to it. |
|
3069 tangle:= Gear^.Angle+1024; |
|
3070 if tangle > 2048 then dec(tangle,2048); |
|
3071 tx:= hwRound(Gear^.X+SignAs(AngleSin(tangle), Gear^.dX)*_6); |
|
3072 ty:= hwRound(Gear^.Y-AngleCos(tangle)*_6); |
|
3073 bx:= hwRound(Gear^.X-SignAs(AngleSin(tangle), Gear^.dX)*_6); |
|
3074 by:= hwRound(Gear^.Y+AngleCos(tangle)*_6); |
3076 *) |
3075 *) |
3077 if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] <> 0) then |
3076 if ((Gear^.IntersectGear <> nil) and (hwRound(Distance(Gear^.X - Gear^.IntersectGear^.X,Gear^.Y-Gear^.IntersectGear^.Y)) < Gear^.Radius*2)) |
3078 begin |
3077 (*or |
3079 inc(Gear^.Tag); |
3078 (((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and $FF00) = 0)) or |
3080 Gear^.doStep:= @doStepPortal; |
3079 (((by and LAND_HEIGHT_MASK) = 0) and ((bx and LAND_WIDTH_MASK) = 0) and ((Land[by, bx] and $FF00) = 0))*) |
3081 // AfterAttack; |
3080 then |
3082 end |
3081 begin |
3083 // How laser checks for infinite |
3082 if CurrentHedgehog <> nil then |
|
3083 if Gear^.IntersectGear = nil then CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 1 |
|
3084 else if Gear^.Tag = 2 then CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 2 |
|
3085 else CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 1; |
|
3086 DeleteGear(Gear) |
|
3087 end |
|
3088 else |
|
3089 begin |
|
3090 if CurrentHedgehog <> nil then |
|
3091 if Gear^.Tag = 2 then CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 1 |
|
3092 else CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 2; |
|
3093 inc(Gear^.Tag); |
|
3094 Gear^.doStep:= @doStepPortal |
|
3095 end |
|
3096 end |
3084 else if (y > cWaterLine + cVisibleWater + Gear^.Radius) or (y < -LAND_WIDTH) or (x > LAND_WIDTH + LAND_WIDTH) or (x < -LAND_WIDTH) then |
3097 else if (y > cWaterLine + cVisibleWater + Gear^.Radius) or (y < -LAND_WIDTH) or (x > LAND_WIDTH + LAND_WIDTH) or (x < -LAND_WIDTH) then |
3085 begin |
3098 begin |
|
3099 if CurrentHedgehog <> nil then |
|
3100 if Gear^.IntersectGear = nil then CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 1 |
|
3101 else if Gear^.Tag = 2 then CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 2 |
|
3102 else CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 1; |
3086 DeleteGear(Gear); |
3103 DeleteGear(Gear); |
3087 // AfterAttack |
|
3088 end; |
3104 end; |
3089 end; |
3105 end; |
3090 |
3106 |
3091 procedure doStepPiano(Gear: PGear); |
3107 procedure doStepPiano(Gear: PGear); |
3092 var r0, r1: LongInt; |
3108 var r0, r1: LongInt; |