155 |
155 |
156 // vector between hedgehog and rope attaching point |
156 // vector between hedgehog and rope attaching point |
157 ropeDx := HHGear^.X - Gear^.X; |
157 ropeDx := HHGear^.X - Gear^.X; |
158 ropeDy := HHGear^.Y - Gear^.Y; |
158 ropeDy := HHGear^.Y - Gear^.Y; |
159 |
159 |
160 if TestCollisionYwithGear(HHGear, 1) = 0 then |
160 if not TestCollisionYwithXYShift(HHGear, 0, 1, 1) then |
161 begin |
161 begin |
162 |
162 |
163 // depending on the rope vector we know which X-side to check for collision |
163 // depending on the rope vector we know which X-side to check for collision |
164 // in order to find out if the hog can still be moved by gravity |
164 // in order to find out if the hog can still be moved by gravity |
165 if ropeDx.isNegative = RopeDy.IsNegative then |
165 if ropeDx.isNegative = RopeDy.IsNegative then |
166 cd:= -1 |
166 cd:= -1 |
167 else |
167 else |
168 cd:= 1; |
168 cd:= 1; |
169 |
169 |
170 // apply gravity if there is no obstacle |
170 // apply gravity if there is no obstacle |
171 if not TestCollisionXwithGear(HHGear, cd) then |
171 if not (TestCollisionXwithXYShift(HHGear, _1*cd, 0, cd, true)) then |
172 HHGear^.dY := HHGear^.dY + cGravity * 16; |
172 HHGear^.dY := HHGear^.dY + cGravity * 16; |
173 |
173 |
174 if (GameFlags and gfMoreWind) <> 0 then |
174 if (GameFlags and gfMoreWind) <> 0 then |
175 // apply wind if there's no obstacle |
175 // apply wind if there's no obstacle |
176 if not TestCollisionXwithGear(HHGear, hwSign(cWindSpeed)) then |
176 if not TestCollisionXwithGear(HHGear, hwSign(cWindSpeed)) then |
191 ///// |
191 ///// |
192 tx := HHGear^.X; |
192 tx := HHGear^.X; |
193 ty := HHGear^.Y; |
193 ty := HHGear^.Y; |
194 |
194 |
195 if ((Gear^.Message and gmDown) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
195 if ((Gear^.Message and gmDown) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
196 if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) |
196 if not (TestCollisionXwithXYShift(HHGear, _2*hwSign(ropeDx), 0, hwSign(ropeDx), true) |
197 or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1, hwSign(ropeDy)))) then |
197 or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1*hwSign(ropeDy), hwSign(ropeDy)))) then |
|
198 //or TestCollisionXwithXYShift(HHGear, _1*hwSign(ropeDx), 0, hwSign(ropeDx), true)) then |
198 Gear^.Elasticity := Gear^.Elasticity + _1_2; |
199 Gear^.Elasticity := Gear^.Elasticity + _1_2; |
199 |
200 |
200 if ((Gear^.Message and gmUp) <> 0) and (Gear^.Elasticity > _30) then |
201 if ((Gear^.Message and gmUp) <> 0) and (Gear^.Elasticity > _30) then |
201 if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx)) |
202 if not (TestCollisionXwithXYShift(HHGear, -_2*hwSign(ropeDx), 0, -hwSign(ropeDx), true) |
202 or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1, -hwSign(ropeDy)))) then |
203 or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1*-hwSign(ropeDy), -hwSign(ropeDy)))) then |
|
204 //or TestCollisionXwithXYShift(HHGear, -_1*hwSign(ropeDx), 0, -hwSign(ropeDx))) then |
203 Gear^.Elasticity := Gear^.Elasticity - _1_2; |
205 Gear^.Elasticity := Gear^.Elasticity - _1_2; |
204 |
206 |
205 HHGear^.X := Gear^.X + mdX * Gear^.Elasticity; |
207 HHGear^.X := Gear^.X + mdX * Gear^.Elasticity; |
206 HHGear^.Y := Gear^.Y + mdY * Gear^.Elasticity; |
208 HHGear^.Y := Gear^.Y + mdY * Gear^.Elasticity; |
207 |
209 |
313 end; |
315 end; |
314 end |
316 end |
315 end; |
317 end; |
316 |
318 |
317 haveCollision := false; |
319 haveCollision := false; |
318 if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
320 if TestCollisionXwithXYShift(HHGear, _1*hwSign(HHGear^.dX), 0, hwSign(HHGear^.dX), true) then |
319 begin |
321 begin |
320 HHGear^.dX := -_0_6 * HHGear^.dX; |
322 HHGear^.dX := -_0_6 * HHGear^.dX; |
321 haveCollision := true |
323 haveCollision := true |
322 end; |
324 end; |
323 if TestCollisionYwithXYShift(HHGear, 0, 1, hwSign(HHGear^.dY)) then |
325 if TestCollisionYwithXYShift(HHGear, 0, 1*hwSign(HHGear^.dY), hwSign(HHGear^.dY)) then |
324 begin |
326 begin |
325 HHGear^.dY := -_0_6 * HHGear^.dY; |
327 HHGear^.dY := -_0_6 * HHGear^.dY; |
326 haveCollision := true |
328 haveCollision := true |
327 end; |
329 end; |
328 |
330 |