594 end; |
594 end; |
595 |
595 |
596 function GenPreview: TPreview; |
596 function GenPreview: TPreview; |
597 var x, y, xx, yy, t, bit: LongInt; |
597 var x, y, xx, yy, t, bit: LongInt; |
598 Preview: TPreview; |
598 Preview: TPreview; |
|
599 isCave: boolean; |
|
600 c: LongWord; |
599 begin |
601 begin |
600 WriteLnToConsole('Generating preview...'); |
602 WriteLnToConsole('Generating preview...'); |
601 GenBlank(EdgeTemplates[SelectTemplate]); |
603 GenBlank(EdgeTemplates[SelectTemplate]); |
602 |
604 |
603 for y:= 0 to 127 do |
605 for y:= 0 to 127 do |
611 for xx:= x * (LAND_WIDTH div 32) + bit * 8 to x * (LAND_WIDTH div 32) + bit * 8 + 7 do |
613 for xx:= x * (LAND_WIDTH div 32) + bit * 8 to x * (LAND_WIDTH div 32) + bit * 8 + 7 do |
612 if Land[yy, xx] <> 0 then inc(t); |
614 if Land[yy, xx] <> 0 then inc(t); |
613 if t > 8 then Preview[y, x]:= Preview[y, x] or ($80 shr bit) |
615 if t > 8 then Preview[y, x]:= Preview[y, x] or ($80 shr bit) |
614 end |
616 end |
615 end; |
617 end; |
616 GenPreview:= Preview |
618 GenPreview:= Preview; |
|
619 |
|
620 isCave:= false; |
|
621 // check for land near top |
|
622 for x:= 0 to LAND_WIDTH-1 do |
|
623 for y:= 0 to 4 do |
|
624 if Land[y, x] <> 0 then |
|
625 begin |
|
626 isCave:= true; |
|
627 break; |
|
628 end; |
|
629 |
|
630 if isCave then |
|
631 begin |
|
632 // experiment hardcoding cave |
|
633 for y:= 0 to LAND_HEIGHT-1 do |
|
634 begin |
|
635 Land[y, 0]:= COLOR_INDESTRUCTIBLE; |
|
636 Land[y, 1]:= COLOR_INDESTRUCTIBLE; |
|
637 Land[y, 2]:= COLOR_INDESTRUCTIBLE; |
|
638 Land[y, LAND_WIDTH-3]:= COLOR_INDESTRUCTIBLE; |
|
639 Land[y, LAND_WIDTH-2]:= COLOR_INDESTRUCTIBLE; |
|
640 Land[y, LAND_WIDTH-1]:= COLOR_INDESTRUCTIBLE; |
|
641 if y mod 32 < 16 then c:= $FF000000 |
|
642 else c:= $FF00FFFF; |
|
643 LandPixels[y, 0]:= c; |
|
644 LandPixels[y, 1]:= c; |
|
645 LandPixels[y, 2]:= c; |
|
646 LandPixels[y, LAND_WIDTH-3]:= c; |
|
647 LandPixels[y, LAND_WIDTH-2]:= c; |
|
648 LandPixels[y, LAND_WIDTH-1]:= c; |
|
649 end; |
|
650 |
|
651 for x:= 0 to LAND_WIDTH-1 do |
|
652 begin |
|
653 Land[0, x]:= COLOR_INDESTRUCTIBLE; |
|
654 Land[1, x]:= COLOR_INDESTRUCTIBLE; |
|
655 Land[2, x]:= COLOR_INDESTRUCTIBLE; |
|
656 if x mod 32 < 16 then c:= $FF000000 |
|
657 else c:= $FF00FFFF; |
|
658 LandPixels[0, x]:= c; |
|
659 LandPixels[1, x]:= c; |
|
660 LandPixels[2, x]:= c; |
|
661 end; |
|
662 end; |
617 end; |
663 end; |
618 |
664 |
619 procedure UpdateLandTexture(Y, Height: LongInt); |
665 procedure UpdateLandTexture(Y, Height: LongInt); |
620 begin |
666 begin |
621 if (Height <= 0) then exit; |
667 if (Height <= 0) then exit; |