3037 DeleteGear(Gear); |
3037 DeleteGear(Gear); |
3038 exit |
3038 exit |
3039 end; |
3039 end; |
3040 end; |
3040 end; |
3041 |
3041 |
|
3042 //////////////////////////////////////////////////////////////////////////////// |
3042 procedure doStepPortal(Gear: PGear); |
3043 procedure doStepPortal(Gear: PGear); |
3043 var tmpGear, iterator: PGear; |
3044 var tmpGear, iterator: PGear; |
3044 begin |
3045 begin |
3045 //if not AllInactive and (Gear^.IntersectGear <> nil) then |
3046 //if not AllInactive and (Gear^.IntersectGear <> nil) then |
3046 if (Gear^.IntersectGear <> nil) then |
3047 if (Gear^.IntersectGear <> nil) then |
3069 |
3070 |
3070 *) |
3071 *) |
3071 end; |
3072 end; |
3072 |
3073 |
3073 procedure doStepMovingPortal(Gear: PGear); |
3074 procedure doStepMovingPortal(Gear: PGear); |
3074 var x, y: LongInt;//, tx, ty, bx, by, tangle: LongInt; |
3075 var x, y, tx, ty: LongInt;//, bx, by, tangle: LongInt; |
3075 begin |
3076 begin |
3076 Gear^.X:= Gear^.X + Gear^.dX; |
3077 Gear^.X:= Gear^.X + Gear^.dX; |
3077 Gear^.Y:= Gear^.Y + Gear^.dY; |
3078 Gear^.Y:= Gear^.Y + Gear^.dY; |
3078 x:= hwRound(Gear^.X); |
3079 x:= hwRound(Gear^.X); |
3079 y:= hwRound(Gear^.Y); |
3080 y:= hwRound(Gear^.Y); |
3080 |
3081 |
3081 if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and ((Land[y, x] and $FF00) <> 0) then |
3082 if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and ((Land[y, x] and $FF00) <> 0) then |
3082 begin |
3083 begin |
|
3084 if not calcSlopeNormal(Gear, x, y, tx, ty, 255) then |
|
3085 begin |
|
3086 DeleteGear(Gear); |
|
3087 EXIT; |
|
3088 end; |
|
3089 //AddFileLog(IntToStr(tx)+' '+IntToStr(ty)); |
|
3090 if Gear^.dX.isNegative then ty:= -ty; |
|
3091 Gear^.DirAngle:= DxDy2Angle(Int2hwFloat(ty),Int2hwFloat(tx)); |
3083 (* |
3092 (* |
3084 This is not quite doing what I want, but basically hoping to avoid portals just sitting out in midair |
3093 This is not quite doing what I want, but basically hoping to avoid portals just sitting out in midair |
3085 Works ok for right angles, aaaand that's about it. |
3094 Works ok for right angles, aaaand that's about it. |
3086 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. |
3095 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. |
3087 tangle:= Gear^.Angle+1024; |
3096 tangle:= Gear^.Angle+1024; |
3089 tx:= hwRound(Gear^.X+SignAs(AngleSin(tangle), Gear^.dX)*_6); |
3098 tx:= hwRound(Gear^.X+SignAs(AngleSin(tangle), Gear^.dX)*_6); |
3090 ty:= hwRound(Gear^.Y-AngleCos(tangle)*_6); |
3099 ty:= hwRound(Gear^.Y-AngleCos(tangle)*_6); |
3091 bx:= hwRound(Gear^.X-SignAs(AngleSin(tangle), Gear^.dX)*_6); |
3100 bx:= hwRound(Gear^.X-SignAs(AngleSin(tangle), Gear^.dX)*_6); |
3092 by:= hwRound(Gear^.Y+AngleCos(tangle)*_6); |
3101 by:= hwRound(Gear^.Y+AngleCos(tangle)*_6); |
3093 *) |
3102 *) |
|
3103 |
|
3104 |
|
3105 |
3094 if ((Gear^.IntersectGear <> nil) and (hwRound(Distance(Gear^.X - Gear^.IntersectGear^.X,Gear^.Y-Gear^.IntersectGear^.Y)) < Gear^.Radius*2)) |
3106 if ((Gear^.IntersectGear <> nil) and (hwRound(Distance(Gear^.X - Gear^.IntersectGear^.X,Gear^.Y-Gear^.IntersectGear^.Y)) < Gear^.Radius*2)) |
3095 (*or |
3107 (*or |
3096 (((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and $FF00) = 0)) or |
3108 (((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and $FF00) = 0)) or |
3097 (((by and LAND_HEIGHT_MASK) = 0) and ((bx and LAND_WIDTH_MASK) = 0) and ((Land[by, bx] and $FF00) = 0))*) |
3109 (((by and LAND_HEIGHT_MASK) = 0) and ((bx and LAND_WIDTH_MASK) = 0) and ((Land[by, bx] and $FF00) = 0))*) |
3098 then |
3110 then |