245 Gear.X:= Gear.X - Sign(Gear.dX)*0.00008; // компенсация сдвига %) |
246 Gear.X:= Gear.X - Sign(Gear.dX)*0.00008; // компенсация сдвига %) |
246 Gear.State:= Gear.State or gstFalling or gstHHJumping; |
247 Gear.State:= Gear.State or gstFalling or gstHHJumping; |
247 exit |
248 exit |
248 end; |
249 end; |
249 end; |
250 end; |
|
251 PrevdX:= Sign(Gear.dX); |
250 if (Gear.Message and gm_Left )<>0 then Gear.dX:= -1.0 else |
252 if (Gear.Message and gm_Left )<>0 then Gear.dX:= -1.0 else |
251 if (Gear.Message and gm_Right )<>0 then Gear.dX:= 1.0 else exit; |
253 if (Gear.Message and gm_Right )<>0 then Gear.dX:= 1.0 else exit; |
|
254 StepTicks:= cHHStepTicks; |
|
255 if PrevdX <> Sign(Gear.dX) then exit; |
252 PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
256 PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
253 StepTicks:= cHHStepTicks; |
|
254 if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
257 if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
255 begin |
258 begin |
256 if not (TestCollisionXwithXYShift(Gear, 0, -6, Sign(Gear.dX)) |
259 if not (TestCollisionXwithXYShift(Gear, 0, -6, Sign(Gear.dX)) |
257 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
260 or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
258 if not (TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) |
261 if not (TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) |
306 //////////////////////////////////////////////////////////////////////////////// |
309 //////////////////////////////////////////////////////////////////////////////// |
307 procedure doStepHedgehogFree(Gear: PGear); |
310 procedure doStepHedgehogFree(Gear: PGear); |
308 begin |
311 begin |
309 //DeleteCI(Gear); |
312 //DeleteCI(Gear); |
310 if not TestCollisionYwithGear(Gear, 1) then |
313 if not TestCollisionYwithGear(Gear, 1) then |
311 if TestCollisionYwithXYShift(Gear, 0, 1, 1) then Gear.Y:= Gear.Y + 1 else |
|
312 begin |
314 begin |
313 if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
315 if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
314 Gear.State:= Gear.State or gstFalling or gstMoving; |
316 Gear.State:= Gear.State or gstFalling or gstMoving; |
315 Gear.dY:= Gear.dY + cGravity |
317 Gear.dY:= Gear.dY + cGravity |
316 end else begin |
318 end else begin |
317 CheckHHDamage(Gear); |
319 CheckHHDamage(Gear); |
318 if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
320 if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
319 and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
321 and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
320 Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
322 Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
321 if Gear.dY > 0 then Gear.dY:= 0; |
323 if Gear.dY > 0 then Gear.dY:= 0; |
322 if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction |
324 if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction |
323 end; |
325 end; |
324 |
326 |
325 if (Gear.State <> 0) then DeleteCI(Gear); |
327 if (Gear.State <> 0) then DeleteCI(Gear); |
326 |
328 |
327 if (Gear.State and gstMoving) <> 0 then |
329 if (Gear.State and gstMoving) <> 0 then |
328 if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
330 if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
329 if ((Gear.State and gstFalling) = 0) then |
331 if ((Gear.State and gstFalling) = 0) then |
330 if abs(Gear.dX) > 0.01 then |
332 if abs(Gear.dX) > 0.01 then |
331 if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.99; Gear.Y:= Gear.Y - 1 end else |
333 if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -1, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.96; Gear.Y:= Gear.Y - 1 end else |
332 if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.98; Gear.Y:= Gear.Y - 2 end else |
334 if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -2, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.93; Gear.Y:= Gear.Y - 2 end else |
333 if not TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.97; Gear.Y:= Gear.Y - 3 end else |
335 if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -3, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.90; Gear.Y:= Gear.Y - 3 end else |
334 if not TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.96; Gear.Y:= Gear.Y - 4 end else |
336 if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -4, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.87; Gear.Y:= Gear.Y - 4 end else |
335 if not TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.95; Gear.Y:= Gear.Y - 5 end else |
337 if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -5, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.84; Gear.Y:= Gear.Y - 5 end else |
336 if abs(Gear.dX) > 0.02 then Gear.dX:= -0.3 * Gear.dX |
338 if abs(Gear.dX) > 0.02 then Gear.dX:= -0.5 * Gear.dX |
337 else begin |
339 else begin |
338 Gear.State:= Gear.State and not gstMoving; |
340 Gear.State:= Gear.State and not gstMoving; |
339 Gear.dX:= 0.0000001 * Sign(Gear.dX) |
341 Gear.dX:= 0.0000001 * Sign(Gear.dX) |
340 end |
342 end |
341 else begin |
343 else begin |
342 Gear.State:= Gear.State and not gstMoving; |
344 Gear.State:= Gear.State and not gstMoving; |
343 Gear.dX:= 0.0000001 * Sign(Gear.dX) |
345 Gear.dX:= 0.0000001 * Sign(Gear.dX) |
344 end |
346 end |
345 else Gear.dX:= -0.8 * Gear.dX; |
347 else Gear.dX:= -Gear.dX; |
346 |
348 |
347 if ((Gear.State and gstFalling) = 0)and |
349 if ((Gear.State and gstFalling) = 0)and |
348 (sqr(Gear.dX) + sqr(Gear.dY) < 0.0008) then |
350 (sqr(Gear.dX) + sqr(Gear.dY) < 0.0008) then |
349 begin |
351 begin |
350 Gear.State:= Gear.State and not gstMoving; |
352 Gear.State:= Gear.State and not gstMoving; |