199 if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
197 if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
200 Gear.X:= Gear.X + Gear.dX; |
198 Gear.X:= Gear.X + Gear.dX; |
201 Gear.dY:= Gear.dY + cGravity; |
199 Gear.dY:= Gear.dY + cGravity; |
202 if (Gear.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
200 if (Gear.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
203 Gear.Y:= Gear.Y + Gear.dY; |
201 Gear.Y:= Gear.Y + Gear.dY; |
204 if (Gear.dY >= 0)and HHTestCollisionYwithGear(Gear, 1) then |
202 if (Gear.dY >= 0)and TestCollisionYwithGear(Gear, 1) then |
205 begin |
203 begin |
206 CheckHHDamage(Gear); |
204 CheckHHDamage(Gear); |
207 if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
205 if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
208 and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
206 and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
209 Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
207 Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
224 if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0)and(StepTicks = 0) then |
222 if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0)and(StepTicks = 0) then |
225 begin |
223 begin |
226 if ((Gear.Message and gm_LJump )<>0) then |
224 if ((Gear.Message and gm_LJump )<>0) then |
227 begin |
225 begin |
228 Gear.Message:= 0; |
226 Gear.Message:= 0; |
229 if not HHTestCollisionYwithGear(Gear, -1) then |
227 if not TestCollisionYwithGear(Gear, -1) then |
230 if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
228 if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
231 if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
229 if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
232 if not (TestCollisionXwithGear(Gear, Sign(Gear.dX)) |
230 if not (TestCollisionXwithGear(Gear, Sign(Gear.dX)) |
233 or HHTestCollisionYwithGear(Gear, -1)) then |
231 or TestCollisionYwithGear(Gear, -1)) then |
234 begin |
232 begin |
235 Gear.dY:= -0.15; |
233 Gear.dY:= -0.15; |
236 Gear.dX:= Sign(Gear.dX) * 0.15; |
234 Gear.dX:= Sign(Gear.dX) * 0.15; |
237 Gear.State:= Gear.State or gstFalling or gstHHJumping; |
235 Gear.State:= Gear.State or gstFalling or gstHHJumping; |
238 exit |
236 exit |
239 end; |
237 end; |
240 end; |
238 end; |
241 if ((Gear.Message and gm_HJump )<>0) then |
239 if ((Gear.Message and gm_HJump )<>0) then |
242 begin |
240 begin |
243 Gear.Message:= 0; |
241 Gear.Message:= 0; |
244 if not HHTestCollisionYwithGear(Gear, -1) then |
242 if not TestCollisionYwithGear(Gear, -1) then |
245 begin |
243 begin |
246 Gear.dY:= -0.20; |
244 Gear.dY:= -0.20; |
247 Gear.dX:= 0.0000001 * Sign(Gear.dX); |
245 Gear.dX:= 0.0000001 * Sign(Gear.dX); |
248 Gear.X:= Gear.X - Sign(Gear.dX)*0.00008; // компенсация сдвига %) |
246 Gear.X:= Gear.X - Sign(Gear.dX)*0.00008; // компенсация сдвига %) |
249 Gear.State:= Gear.State or gstFalling or gstHHJumping; |
247 Gear.State:= Gear.State or gstFalling or gstHHJumping; |
255 PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
253 PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
256 StepTicks:= cStepTicks; |
254 StepTicks:= cStepTicks; |
257 if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
255 if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
258 begin |
256 begin |
259 if not (TestCollisionXwithXYShift(Gear, 0, -6, Sign(Gear.dX)) |
257 if not (TestCollisionXwithXYShift(Gear, 0, -6, Sign(Gear.dX)) |
260 or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
258 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
261 if not (TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) |
259 if not (TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) |
262 or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
260 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
263 if not (TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX)) |
261 if not (TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX)) |
264 or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
262 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
265 if not (TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX)) |
263 if not (TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX)) |
266 or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
264 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
267 if not (TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) |
265 if not (TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) |
268 or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
266 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
269 if not (TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) |
267 if not (TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) |
270 or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
268 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
271 end; |
269 end; |
272 if not TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.X:= Gear.X + Gear.dX; |
270 if not TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.X:= Gear.X + Gear.dX; |
273 SetAllHHToActive; |
271 SetAllHHToActive; |
274 |
272 |
275 if not HHTestCollisionYwithGear(Gear, 1) then |
273 if not TestCollisionYwithGear(Gear, 1) then |
276 begin |
274 begin |
277 Gear.Y:= Gear.Y + 1; |
275 Gear.Y:= Gear.Y + 1; |
278 if not HHTestCollisionYwithGear(Gear, 1) then |
276 if not TestCollisionYwithGear(Gear, 1) then |
279 begin |
277 begin |
280 Gear.Y:= Gear.Y + 1; |
278 Gear.Y:= Gear.Y + 1; |
281 if not HHTestCollisionYwithGear(Gear, 1) then |
279 if not TestCollisionYwithGear(Gear, 1) then |
282 begin |
280 begin |
283 Gear.Y:= Gear.Y + 1; |
281 Gear.Y:= Gear.Y + 1; |
284 if not HHTestCollisionYwithGear(Gear, 1) then |
282 if not TestCollisionYwithGear(Gear, 1) then |
285 begin |
283 begin |
286 Gear.Y:= Gear.Y + 1; |
284 Gear.Y:= Gear.Y + 1; |
287 if not HHTestCollisionYwithGear(Gear, 1) then |
285 if not TestCollisionYwithGear(Gear, 1) then |
288 begin |
286 begin |
289 Gear.Y:= Gear.Y + 1; |
287 Gear.Y:= Gear.Y + 1; |
290 if not HHTestCollisionYwithGear(Gear, 1) then |
288 if not TestCollisionYwithGear(Gear, 1) then |
291 begin |
289 begin |
292 Gear.Y:= Gear.Y + 1; |
290 Gear.Y:= Gear.Y + 1; |
293 if not HHTestCollisionYwithGear(Gear, 1) then |
291 if not TestCollisionYwithGear(Gear, 1) then |
294 begin |
292 begin |
295 Gear.Y:= Gear.Y - 6; |
293 Gear.Y:= Gear.Y - 6; |
296 Gear.dY:= 0; |
294 Gear.dY:= 0; |
297 Gear.dX:= 0.0000001 * Sign(Gear.dX); |
295 Gear.dX:= 0.0000001 * Sign(Gear.dX); |
298 Gear.State:= Gear.State or gstFalling |
296 Gear.State:= Gear.State or gstFalling |
308 |
306 |
309 //////////////////////////////////////////////////////////////////////////////// |
307 //////////////////////////////////////////////////////////////////////////////// |
310 procedure doStepHedgehogFree(Gear: PGear); |
308 procedure doStepHedgehogFree(Gear: PGear); |
311 begin |
309 begin |
312 //DeleteCI(Gear); |
310 //DeleteCI(Gear); |
313 if not HHTestCollisionYwithGear(Gear, 1) then |
311 if not TestCollisionYwithGear(Gear, 1) then |
314 begin |
312 begin |
315 if (Gear.dY < 0) and HHTestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
313 if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
316 Gear.State:= Gear.State or gstFalling or gstMoving; |
314 Gear.State:= Gear.State or gstFalling or gstMoving; |
317 Gear.dY:= Gear.dY + cGravity |
315 Gear.dY:= Gear.dY + cGravity |
318 end else begin |
316 end else begin |
319 CheckHHDamage(Gear); |
317 CheckHHDamage(Gear); |
320 if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
318 if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |