525 LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor |
525 LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor |
526 end |
526 end |
527 end; |
527 end; |
528 end; |
528 end; |
529 |
529 |
|
530 type TWrapNeeded = (wnNone, wnLeft, wnRight); |
530 |
531 |
531 // |
532 // |
532 // - (dX, dY) - direction, vector of length = 0.5 |
533 // - (dX, dY) - direction, vector of length = 0.5 |
533 // |
534 // |
534 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
535 function DrawTunnel_real(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt): TWrapNeeded; |
535 var nx, ny, dX8, dY8: hwFloat; |
536 var nx, ny, dX8, dY8: hwFloat; |
536 i, t, tx, ty, by, bx, stX, stY, ddy, ddx: Longint; |
537 i, t, tx, ty, by, bx, stX, stY, ddy, ddx: Longint; |
537 despeckle : Boolean; |
538 despeckle : Boolean; |
538 begin // (-dY, dX) is (dX, dY) rotated by PI/2 |
539 begin // (-dY, dX) is (dX, dY) rotated by PI/2 |
|
540 DrawTunnel_real:= wnNone; |
|
541 |
539 stY:= hwRound(Y); |
542 stY:= hwRound(Y); |
540 stX:= hwRound(X); |
543 stX:= hwRound(X); |
541 |
544 |
542 despeckle:= HalfWidth > 1; |
545 despeckle:= HalfWidth > 1; |
543 |
546 |
635 end; |
638 end; |
636 nx:= nx - dY; |
639 nx:= nx - dY; |
637 ny:= ny + dX; |
640 ny:= ny + dX; |
638 end; |
641 end; |
639 |
642 |
640 tx:= Max(stX - HalfWidth * 2 - 4 - abs(hwRound(dX * ticks)), 0); |
643 tx:= stX - HalfWidth * 2 - 4 - abs(hwRound(dX * ticks)); |
|
644 ddx:= stX + HalfWidth * 2 + 4 + abs(hwRound(dX * ticks)); |
|
645 |
|
646 if WorldEdge = weWrap then |
|
647 begin |
|
648 if (tx < leftX) or (ddx < leftX) then |
|
649 DrawTunnel_real:= wnLeft |
|
650 else if (tx > rightX) or (ddx > rightX) then |
|
651 DrawTunnel_real:= wnRight; |
|
652 end; |
|
653 |
|
654 tx:= Max(tx, 0); |
641 ty:= Max(stY - HalfWidth * 2 - 4 - abs(hwRound(dY * ticks)), 0); |
655 ty:= Max(stY - HalfWidth * 2 - 4 - abs(hwRound(dY * ticks)), 0); |
642 ddx:= Min(stX + HalfWidth * 2 + 4 + abs(hwRound(dX * ticks)), LAND_WIDTH) - tx; |
656 ddx:= Min(ddx, LAND_WIDTH) - tx; |
643 ddy:= Min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - ty; |
657 ddy:= Min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - ty; |
644 |
658 |
645 UpdateLandTexture(tx, ddx, ty, ddy, false) |
659 UpdateLandTexture(tx, ddx, ty, ddy, false) |
|
660 end; |
|
661 |
|
662 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
|
663 var wn: TWrapNeeded; |
|
664 begin |
|
665 wn:= DrawTunnel_real(X, Y, dX, dY, ticks, HalfWidth); |
|
666 if wn <> wnNone then |
|
667 begin |
|
668 if wn = wnLeft then |
|
669 DrawTunnel_real(X + int2hwFloat(playWidth), Y, dX, dY, ticks, HalfWidth) |
|
670 else |
|
671 DrawTunnel_real(X - int2hwFloat(playWidth), Y, dX, dY, ticks, HalfWidth); |
|
672 end; |
646 end; |
673 end; |
647 |
674 |
648 function TryPlaceOnLandSimple(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean; inline; |
675 function TryPlaceOnLandSimple(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean; inline; |
649 var lf: Word; |
676 var lf: Word; |
650 begin |
677 begin |