6374 if Gear^.Pos = 0 then |
6374 if Gear^.Pos = 0 then |
6375 doStepFallingGear(Gear); |
6375 doStepFallingGear(Gear); |
6376 |
6376 |
6377 (* Check if duck is near water surface |
6377 (* Check if duck is near water surface |
6378 (Karma is distance from water) *) |
6378 (Karma is distance from water) *) |
6379 if (Gear^.Pos in [0, 5, 6]) and (cWaterLine <= hwRound(Gear^.Y) + Gear^.Karma) then |
6379 if (not (Gear^.Pos in [1, 2])) and (cWaterLine <= hwRound(Gear^.Y) + Gear^.Karma) then |
6380 begin |
6380 begin |
6381 if cWaterLine = hwRound(Gear^.Y) + Gear^.Karma then |
6381 if cWaterLine = hwRound(Gear^.Y) + Gear^.Karma then |
6382 begin |
6382 begin |
6383 PlaySound(sndDroplet2); |
6383 // Let's make that duck swim! |
6384 if Gear^.dY > _0_4 then |
6384 // Does the duck come FROM the Sea edge? (left or right) |
|
6385 if ((Gear^.Pos in [3, 7]) and (cWindSpeed > _0)) or ((Gear^.Pos in [4, 8]) and (cWindSpeed < _0)) then |
|
6386 begin |
6385 PlaySound(sndDuckWater); |
6387 PlaySound(sndDuckWater); |
6386 Gear^.Pos:= 1; |
6388 Gear^.Angle:= 0; |
6387 Gear^.dY:= _0; |
6389 Gear^.Pos:= 1; |
|
6390 Gear^.dY:= _0; |
|
6391 end; |
|
6392 |
|
6393 // Duck comes either falling (usual case) or was rising from below |
|
6394 if Gear^.Pos in [0, 5, 6] then |
|
6395 begin |
|
6396 PlaySound(sndDroplet2); |
|
6397 if Gear^.dY > _0_4 then |
|
6398 PlaySound(sndDuckWater); |
|
6399 Gear^.Pos:= 1; |
|
6400 Gear^.dY:= _0; |
|
6401 end; |
6388 end |
6402 end |
6389 else if Gear^.Pos = 0 then |
6403 else if Gear^.Pos = 0 then |
6390 Gear^.Pos:= 5; |
6404 Gear^.Pos:= 5; |
6391 end; |
6405 end; |
6392 |
6406 |
6438 end; |
6452 end; |
6439 |
6453 |
6440 |
6454 |
6441 // Rotate duck and change direction when reaching Sea world edge (Pos 3 or 4) |
6455 // Rotate duck and change direction when reaching Sea world edge (Pos 3 or 4) |
6442 if (WorldEdge = weSea) and (not (Gear^.Pos in [3,4])) then |
6456 if (WorldEdge = weSea) and (not (Gear^.Pos in [3,4])) then |
6443 // Left edge |
6457 // Swimming TOWARDS left edge |
6444 if (LeftX >= hwRound(Gear^.X) - Gear^.Karma) then |
6458 if (LeftX >= hwRound(Gear^.X) - Gear^.Karma) and ((cWindSpeed < _0) or (Gear^.Pos in [0, 7])) then |
6445 begin |
6459 begin |
6446 // Turn duck when reaching edge the first time |
6460 // Turn duck when reaching edge the first time |
6447 if not (Gear^.Pos in [3,7]) then |
6461 if not (Gear^.Pos in [3,7]) then |
6448 begin |
6462 begin |
6449 if Gear^.Tag = 1 then |
6463 if Gear^.Tag = 1 then |
6464 // We are coming from inside the Sea, go into “surfacing” mode |
6478 // We are coming from inside the Sea, go into “surfacing” mode |
6465 Gear^.Pos:= 7; |
6479 Gear^.Pos:= 7; |
6466 |
6480 |
6467 end |
6481 end |
6468 |
6482 |
6469 // Right edge (similar to left edge) |
6483 // Swimming TOWARDS right edge (similar to left edge) |
6470 else if (RightX <= hwRound(Gear^.X) + Gear^.Karma) then |
6484 else if (RightX <= hwRound(Gear^.X) + Gear^.Karma) and ((cWindSpeed > _0) or (Gear^.Pos in [0, 8])) then |
6471 begin |
6485 begin |
6472 if not (Gear^.Pos in [4,8]) then |
6486 if not (Gear^.Pos in [4,8]) then |
6473 begin |
6487 begin |
6474 if Gear^.Tag = 1 then |
6488 if Gear^.Tag = 1 then |
6475 Gear^.Angle:= 270 |
6489 Gear^.Angle:= 270 |