equal
deleted
inserted
replaced
59 var Count: Longword = 0; |
59 var Count: Longword = 0; |
60 crects: array[0..MAXRECTSINDEX] of TCollisionEntry; |
60 crects: array[0..MAXRECTSINDEX] of TCollisionEntry; |
61 |
61 |
62 procedure AddGearCR(Gear: PGear); |
62 procedure AddGearCR(Gear: PGear); |
63 begin |
63 begin |
64 {$IFDEF DEBUGFILE}AddFileLog('AddCR crects count = ' + inttostr(Count));{$ENDIF} |
|
65 TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true); |
64 TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true); |
66 with crects[Count] do |
65 with crects[Count] do |
67 begin |
66 begin |
68 X:= round(Gear.X); |
67 X:= round(Gear.X); |
69 Y:= round(Gear.Y); |
68 Y:= round(Gear.Y); |
84 end |
83 end |
85 end; |
84 end; |
86 |
85 |
87 procedure DeleteCR(Gear: PGear); |
86 procedure DeleteCR(Gear: PGear); |
88 begin |
87 begin |
89 {$IFDEF DEBUGFILE}AddFileLog('DelCR crects count = ' + inttostr(Count) + ' deleting ' + inttostr(Gear.CollIndex));{$ENDIF} |
|
90 if Gear.CollIndex < Pred(Count) then |
88 if Gear.CollIndex < Pred(Count) then |
91 begin |
89 begin |
92 crects[Gear.CollIndex]:= crects[Pred(Count)]; |
90 crects[Gear.CollIndex]:= crects[Pred(Count)]; |
93 crects[Gear.CollIndex].cGear.CollIndex:= Gear.CollIndex |
91 crects[Gear.CollIndex].cGear.CollIndex:= Gear.CollIndex |
94 end; |
92 end; |
102 begin |
100 begin |
103 Result:= false; |
101 Result:= false; |
104 if Count = 0 then exit; |
102 if Count = 0 then exit; |
105 x1:= round(Gear.X); |
103 x1:= round(Gear.X); |
106 y1:= round(Gear.Y); |
104 y1:= round(Gear.Y); |
107 {if (Gear.State and gstOutOfHH) = 0 then |
105 |
108 begin |
|
109 p:= PHedgehog(Gear.Hedgehog)^.Gear; |
|
110 if (p <> nil) and |
|
111 ((x1 + Gear.HalfWidth < round(p.X) - p.HalfWidth) |
|
112 or (x1 - Gear.HalfWidth > round(p.X) + p.HalfWidth) |
|
113 or (y1 - Gear.HalfHeight > round(p.Y) + p.HalfHeight) |
|
114 or (y1 + Gear.HalfHeight < round(p.Y) - p.HalfHeight)) then Gear.State:= Gear.State or gstOutOfHH; |
|
115 end; } |
|
116 if forX then |
106 if forX then |
117 begin |
107 begin |
118 x1:= x1 + Dir*Gear.HalfWidth; |
108 x1:= x1 + Dir*Gear.HalfWidth; |
119 x2:= x1; |
109 x2:= x1; |
120 y2:= y1 + Gear.HalfHeight - 1; |
110 y2:= y1 + Gear.HalfHeight - 1; |
128 end; |
118 end; |
129 |
119 |
130 for i:= 0 to Pred(Count) do |
120 for i:= 0 to Pred(Count) do |
131 with crects[i] do |
121 with crects[i] do |
132 if (Gear.CollIndex <> i) |
122 if (Gear.CollIndex <> i) |
133 // if ((p.Kind = gtHedgehog) and ((p.Hedgehog <> Gear.Hedgehog) or ((Gear.State and gstOutOfHH) <> 0))) |
|
134 and (x1 <= X + HWidth) |
123 and (x1 <= X + HWidth) |
135 and (x2 >= X - HWidth) |
124 and (x2 >= X - HWidth) |
136 and (y1 <= Y + HHeight) |
125 and (y1 <= Y + HHeight) |
137 and (y2 >= Y - HHeight) then |
126 and (y2 >= Y - HHeight) then |
138 begin |
127 begin |