1317 |
1317 |
1318 HHGear := PHedgehog(Gear^.Hedgehog)^.Gear; |
1318 HHGear := PHedgehog(Gear^.Hedgehog)^.Gear; |
1319 DeleteCI(HHGear); |
1319 DeleteCI(HHGear); |
1320 |
1320 |
1321 if (HHGear^.State and gstMoving) <> 0 then |
1321 if (HHGear^.State and gstMoving) <> 0 then |
1322 begin |
1322 begin |
1323 if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
1323 if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
1324 if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, -1) then HHGear^.dY := _0; |
1324 if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, -1) then HHGear^.dY := _0; |
1325 |
1325 |
1326 HHGear^.X := HHGear^.X + HHGear^.dX; |
1326 HHGear^.X := HHGear^.X + HHGear^.dX; |
1327 Gear^.X := Gear^.X + HHGear^.dX; |
1327 Gear^.X := Gear^.X + HHGear^.dX; |
1328 |
1328 |
1329 if TestCollisionYwithGear(HHGear, 1) then |
1329 if TestCollisionYwithGear(HHGear, 1) then |
1330 begin |
1330 begin |
1331 CheckHHDamage(HHGear); |
1331 CheckHHDamage(HHGear); |
1332 HHGear^.dY := _0; |
1332 HHGear^.dY := _0 |
1333 //HHGear^.State:= HHGear^.State and not (gstHHJumping or gstHHHJump); |
1333 //HHGear^.State:= HHGear^.State and not (gstHHJumping or gstHHHJump); |
1334 end |
1334 end |
1335 else |
1335 else |
1336 begin |
1336 begin |
1337 HHGear^.Y := HHGear^.Y + HHGear^.dY; |
1337 HHGear^.Y := HHGear^.Y + HHGear^.dY; |
1338 Gear^.Y := Gear^.Y + HHGear^.dY; |
1338 Gear^.Y := Gear^.Y + HHGear^.dY; |
1339 HHGear^.dY := HHGear^.dY + cGravity; |
1339 HHGear^.dY := HHGear^.dY + cGravity |
1340 end; |
1340 end; |
1341 |
1341 |
1342 tt := Gear^.Elasticity; |
1342 tt := Gear^.Elasticity; |
1343 tx := _0; |
1343 tx := _0; |
1344 ty := _0; |
1344 ty := _0; |
1345 while tt > _20 do |
1345 while tt > _20 do |
1346 begin |
1346 begin |
1347 if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
1347 if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
1348 or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
1348 or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
1349 begin |
1349 begin |
1350 Gear^.X := Gear^.X + tx; |
1350 Gear^.X := Gear^.X + tx; |
1351 Gear^.Y := Gear^.Y + ty; |
1351 Gear^.Y := Gear^.Y + ty; |
1352 Gear^.Elasticity := tt; |
1352 Gear^.Elasticity := tt; |
1353 Gear^.doStep := @doStepRopeWork; |
1353 Gear^.doStep := @doStepRopeWork; |
1354 PlaySound(sndRopeAttach); |
1354 PlaySound(sndRopeAttach); |
1357 |
1357 |
1358 RemoveFromAmmo; |
1358 RemoveFromAmmo; |
1359 |
1359 |
1360 tt := _0; |
1360 tt := _0; |
1361 exit |
1361 exit |
1362 end; |
1362 end; |
1363 tx := tx + Gear^.dX + Gear^.dX; |
1363 tx := tx + Gear^.dX + Gear^.dX; |
1364 ty := ty + Gear^.dY + Gear^.dY; |
1364 ty := ty + Gear^.dY + Gear^.dY; |
1365 tt := tt - _2; |
1365 tt := tt - _2; |
1366 end; |
1366 end; |
1367 end; |
1367 end; |
1368 |
1368 |
1369 CheckCollision(Gear); |
1369 CheckCollision(Gear); |
1370 |
1370 |
1371 if (Gear^.State and gstCollision) <> 0 then |
1371 if (Gear^.State and gstCollision) <> 0 then |
1372 if Gear^.Elasticity < _10 then |
1372 if Gear^.Elasticity < _10 then |
1373 Gear^.Elasticity := _10000 |
1373 Gear^.Elasticity := _10000 |
1374 else |
1374 else |
1375 begin |
1375 begin |
1376 Gear^.doStep := @doStepRopeWork; |
1376 Gear^.doStep := @doStepRopeWork; |
1377 PlaySound(sndRopeAttach); |
1377 PlaySound(sndRopeAttach); |
1378 with HHGear^ do |
1378 with HHGear^ do |
|
1379 begin |
1379 State := State and not (gstAttacking or gstHHJumping or gstHHHJump); |
1380 State := State and not (gstAttacking or gstHHJumping or gstHHHJump); |
|
1381 Message := Message and not gmAttack |
|
1382 end; |
1380 |
1383 |
1381 RemoveFromAmmo; |
1384 RemoveFromAmmo; |
1382 |
1385 |
1383 exit |
1386 exit |
1384 end; |
1387 end; |
1385 |
1388 |
1386 if (Gear^.Elasticity > Gear^.Friction) |
1389 if (Gear^.Elasticity > Gear^.Friction) |
1387 or ((Gear^.Message and gmAttack) = 0) |
1390 or ((Gear^.Message and gmAttack) = 0) |
1388 or ((HHGear^.State and gstHHDriven) = 0) |
1391 or ((HHGear^.State and gstHHDriven) = 0) |
1389 or (HHGear^.Damage > 0) then |
1392 or (HHGear^.Damage > 0) then |
1390 begin |
1393 begin |
1391 with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
1394 with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
1392 begin |
1395 begin |
1393 State := State and not gstAttacking; |
1396 State := State and not gstAttacking; |
1394 Message := Message and not gmAttack |
1397 Message := Message and not gmAttack |
1395 end; |
1398 end; |
1396 DeleteGear(Gear) |
1399 DeleteGear(Gear) |
1397 end |
1400 end |
1398 end; |
1401 end; |
1399 |
1402 |
1400 procedure doStepRope(Gear: PGear); |
1403 procedure doStepRope(Gear: PGear); |
1401 begin |
1404 begin |
1402 Gear^.dX := - Gear^.dX; |
1405 Gear^.dX := - Gear^.dX; |