3133 iterator^.dY:= s * iterator^.dX; |
3133 iterator^.dY:= s * iterator^.dX; |
3134 end; |
3134 end; |
3135 |
3135 |
3136 iterator:= iterator^.NextGear; |
3136 iterator:= iterator^.NextGear; |
3137 end; |
3137 end; |
3138 |
|
3139 (* |
|
3140 |
|
3141 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. |
|
3142 |
|
3143 *) |
|
3144 end; |
3138 end; |
3145 |
3139 |
3146 procedure doStepMovingPortal(Gear: PGear); |
3140 procedure doStepMovingPortal(Gear: PGear); |
3147 var x, y, tx, ty: LongInt;//, bx, by, tangle: LongInt; |
3141 var x, y, tx, ty: LongInt;//, bx, by, tangle: LongInt; |
3148 s, dx, dy: hwFloat; |
3142 s, dx, dy: hwFloat; |
3183 Gear^.dX:= dx; |
3177 Gear^.dX:= dx; |
3184 Gear^.dY:= dy; |
3178 Gear^.dY:= dy; |
3185 |
3179 |
3186 Gear^.DirAngle:= DxDy2Angle(-dy,dx); |
3180 Gear^.DirAngle:= DxDy2Angle(-dy,dx); |
3187 if not Gear^.dX.isNegative then Gear^.DirAngle:= 180-Gear^.DirAngle; |
3181 if not Gear^.dX.isNegative then Gear^.DirAngle:= 180-Gear^.DirAngle; |
3188 (* |
|
3189 This is not quite doing what I want, but basically hoping to avoid portals just sitting out in midair |
|
3190 Works ok for right angles, aaaand that's about it. |
|
3191 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. |
|
3192 tangle:= Gear^.Angle+1024; |
|
3193 if tangle > 2048 then dec(tangle,2048); |
|
3194 tx:= hwRound(Gear^.X+SignAs(AngleSin(tangle), Gear^.dX)*_6); |
|
3195 ty:= hwRound(Gear^.Y-AngleCos(tangle)*_6); |
|
3196 bx:= hwRound(Gear^.X-SignAs(AngleSin(tangle), Gear^.dX)*_6); |
|
3197 by:= hwRound(Gear^.Y+AngleCos(tangle)*_6); |
|
3198 *) |
|
3199 |
|
3200 |
|
3201 |
3182 |
3202 if ((Gear^.IntersectGear <> nil) and (hwRound(Distance(Gear^.X - Gear^.IntersectGear^.X,Gear^.Y-Gear^.IntersectGear^.Y)) < Gear^.Radius*2)) |
3183 if ((Gear^.IntersectGear <> nil) and (hwRound(Distance(Gear^.X - Gear^.IntersectGear^.X,Gear^.Y-Gear^.IntersectGear^.Y)) < Gear^.Radius*2)) |
3203 (*or |
|
3204 (((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and $FF00) = 0)) or |
|
3205 (((by and LAND_HEIGHT_MASK) = 0) and ((bx and LAND_WIDTH_MASK) = 0) and ((Land[by, bx] and $FF00) = 0))*) |
|
3206 then |
3184 then |
3207 begin |
3185 begin |
3208 if CurrentHedgehog <> nil then |
3186 if CurrentHedgehog <> nil then |
3209 if Gear^.IntersectGear = nil then CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 1 |
3187 if Gear^.IntersectGear = nil then CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 1 |
3210 else if Gear^.Tag = 2 then CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 2 |
3188 else if Gear^.Tag = 2 then CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].Timer:= 2 |