47 function DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword): Longword; |
47 function DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword): Longword; |
48 procedure DumpLandToLog(x, y, r: LongInt); |
48 procedure DumpLandToLog(x, y, r: LongInt); |
49 procedure DrawIceBreak(x, y, iceRadius, iceHeight: Longint); |
49 procedure DrawIceBreak(x, y, iceRadius, iceHeight: Longint); |
50 function TryPlaceOnLandSimple(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean; inline; |
50 function TryPlaceOnLandSimple(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean; inline; |
51 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean; inline; |
51 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean; inline; |
52 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap: boolean; LandFlags: Word): boolean; |
52 function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word): boolean; inline; |
|
53 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force: boolean; LandFlags: Word): boolean; |
53 function GetPlaceCollisionTex(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): PTexture; |
54 function GetPlaceCollisionTex(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): PTexture; |
54 |
55 |
55 implementation |
56 implementation |
56 uses SDLh, uLandTexture, uTextures, uVariables, uUtils, uDebug; |
57 uses SDLh, uLandTexture, uTextures, uVariables, uUtils, uDebug; |
57 |
58 |
611 begin |
612 begin |
612 if indestructible then |
613 if indestructible then |
613 lf:= lfIndestructible |
614 lf:= lfIndestructible |
614 else |
615 else |
615 lf:= 0; |
616 lf:= 0; |
616 TryPlaceOnLandSimple:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, lf); |
617 TryPlaceOnLandSimple:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, false, lf); |
617 end; |
618 end; |
618 |
619 |
619 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean; inline; |
620 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean; inline; |
620 begin |
621 begin |
621 TryPlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, LandFlags); |
622 TryPlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, false, LandFlags); |
622 end; |
623 end; |
623 |
624 |
624 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap: boolean; LandFlags: Word): boolean; |
625 function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word): boolean; inline; |
|
626 begin |
|
627 ForcePlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, true, true, true, LandFlags) |
|
628 end; |
|
629 |
|
630 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force: boolean; LandFlags: Word): boolean; |
625 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt; |
631 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt; |
626 p: PByteArray; |
632 p: PByteArray; |
627 Image: PSDL_Surface; |
633 Image: PSDL_Surface; |
628 indestructible: boolean; |
634 indestructible: boolean; |
629 begin |
635 begin |
653 4: for y:= 0 to Pred(h) do |
659 4: for y:= 0 to Pred(h) do |
654 begin |
660 begin |
655 for x:= 0 to Pred(w) do |
661 for x:= 0 to Pred(w) do |
656 if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then |
662 if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then |
657 if (outOfMap and |
663 if (outOfMap and |
658 ((cpY + y) < LAND_HEIGHT) and ((cpY + y) >= 0) and |
664 ((cpY + y) < LAND_HEIGHT) and ((cpY + y) >= 0) and |
659 ((cpX + x) < LAND_WIDTH) and ((cpX + x) >= 0) and |
665 ((cpX + x) < LAND_WIDTH) and ((cpX + x) >= 0) and |
660 (Land[cpY + y, cpX + x] <> 0)) or |
666 ((not force) or (Land[cpY + y, cpX + x] <> 0))) or |
661 |
667 |
662 (not outOfMap and |
668 (not outOfMap and |
663 (((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or |
669 (((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or |
664 ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) or |
670 ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) or |
665 (Land[cpY + y, cpX + x] <> 0))) then |
671 ((not force) or (Land[cpY + y, cpX + x] <> 0)))) then |
666 begin |
672 begin |
667 if SDL_MustLock(Image) then |
673 if SDL_MustLock(Image) then |
668 SDL_UnlockSurface(Image); |
674 SDL_UnlockSurface(Image); |
669 exit |
675 exit |
670 end; |
676 end; |