36 |
36 |
37 implementation |
37 implementation |
38 uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils, |
38 uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils, |
39 uVariables, uUtils, uCommands, Adler32, uDebug, uLandPainted, uTextures; |
39 uVariables, uUtils, uCommands, Adler32, uDebug, uLandPainted, uTextures; |
40 |
40 |
41 operator=(const a, b: direction) c: Boolean; |
41 operator = (const a, b: direction) c: Boolean; |
42 begin |
42 begin |
43 c := (a.x = b.x) and (a.y = b.y); |
43 c := (a.x = b.x) and (a.y = b.y); |
44 end; |
44 end; |
45 |
45 |
46 type TPixAr = record |
46 type TPixAr = record |
683 tries := 0; |
683 tries := 0; |
684 found_cell := false; |
684 found_cell := false; |
685 if getrandom(2) = 1 then next_dir_clockwise := true |
685 if getrandom(2) = 1 then next_dir_clockwise := true |
686 else next_dir_clockwise := false; |
686 else next_dir_clockwise := false; |
687 |
687 |
688 while (tries < 5) and not found_cell do |
688 while (tries < 5) and (not found_cell) do |
689 begin |
689 begin |
690 if when_seen(x + dir.x, y + dir.y) = current_step then //we are seeing ourselves, try another direction |
690 if when_seen(x + dir.x, y + dir.y) = current_step then //we are seeing ourselves, try another direction |
691 begin |
691 begin |
692 //we have already seen the target cell, decide if we should remove the wall anyway |
692 //we have already seen the target cell, decide if we should remove the wall anyway |
693 //(or put a wall there if maze_inverted, but we are not doing that right now) |
693 //(or put a wall there if maze_inverted, but we are not doing that right now) |
1074 begin |
1074 begin |
1075 if (Land[y, x-1] = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x-1] |
1075 if (Land[y, x-1] = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x-1] |
1076 else if (Land[y, x+1] = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x+1] |
1076 else if (Land[y, x+1] = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x+1] |
1077 else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y-1, x] |
1077 else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y-1, x] |
1078 else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y+1, x]; |
1078 else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y+1, x]; |
1079 if (((LandPixels[y,x] and AMask) shr AShift) > 10) then LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (128 shl AShift) |
1079 if (((LandPixels[y,x] and AMask) shr AShift) > 10) then LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (128 shl AShift) |
1080 end; |
1080 end; |
1081 Land[y,x]:= lfObject |
1081 Land[y,x]:= lfObject |
1082 end |
1082 end |
1083 else if (Land[y, x] = 0) and |
1083 else if (Land[y, x] = 0) and |
1084 (((Land[y, x-1] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y+2,x] = lfBasic)) or |
1084 (((Land[y, x-1] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y+2,x] = lfBasic)) or |
1094 begin |
1094 begin |
1095 if (Land[y, x-1] = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x-1] |
1095 if (Land[y, x-1] = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x-1] |
1096 else if (Land[y, x+1] = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x+1] |
1096 else if (Land[y, x+1] = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x+1] |
1097 else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y+1, x] |
1097 else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y+1, x] |
1098 else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y-1, x]; |
1098 else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y-1, x]; |
1099 if (((LandPixels[y,x] and AMask) shr AShift) > 10) then LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (64 shl AShift) |
1099 if (((LandPixels[y,x] and AMask) shr AShift) > 10) then LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (64 shl AShift) |
1100 end; |
1100 end; |
1101 Land[y,x]:= lfObject |
1101 Land[y,x]:= lfObject |
1102 end; |
1102 end; |
1103 |
1103 |
1104 AddProgress(); |
1104 AddProgress(); |