721 if getrandom(2) = 1 then next_dir_clockwise := true |
721 if getrandom(2) = 1 then next_dir_clockwise := true |
722 else next_dir_clockwise := false; |
722 else next_dir_clockwise := false; |
723 |
723 |
724 while (tries < 5) and not found_cell do |
724 while (tries < 5) and not found_cell do |
725 begin |
725 begin |
726 if when_seen(x + dir.x, y + dir.y) = current_step then //we're seeing ourselves, try another direction |
726 if when_seen(x + dir.x, y + dir.y) = current_step then //we are seeing ourselves, try another direction |
727 begin |
727 begin |
728 //we have already seen the target cell, decide if we should remove the wall anyway |
728 //we have already seen the target cell, decide if we should remove the wall anyway |
729 //(or put a wall there if maze_inverted, but we're not doing that right now) |
729 //(or put a wall there if maze_inverted, but we are not doing that right now) |
730 if not maze_inverted and (GetRandom(braidness) = 0) then |
730 if not maze_inverted and (GetRandom(braidness) = 0) then |
731 //or just warn that inverted+braid+indestructible terrain != good idea |
731 //or just warn that inverted+braid+indestructible terrain != good idea |
732 begin |
732 begin |
733 case dir.x of |
733 case dir.x of |
734 -1: if x > 0 then ywalls[x-1, y] := false; |
734 -1: if x > 0 then ywalls[x-1, y] := false; |
777 came_from_pos[current_step] := came_from_pos[current_step] + 1; |
777 came_from_pos[current_step] := came_from_pos[current_step] + 1; |
778 came_from[current_step, came_from_pos[current_step]].x := x; |
778 came_from[current_step, came_from_pos[current_step]].x := x; |
779 came_from[current_step, came_from_pos[current_step]].y := y; |
779 came_from[current_step, came_from_pos[current_step]].y := y; |
780 found_cell := true; |
780 found_cell := true; |
781 end |
781 end |
782 else //we're seeing someone else, quit |
782 else //we are seeing someone else, quit |
783 begin |
783 begin |
784 step_done[current_step] := true; |
784 step_done[current_step] := true; |
785 found_cell := true; |
785 found_cell := true; |
786 end; |
786 end; |
787 |
787 |
1282 |
1282 |
1283 function GenPreview: TPreview; |
1283 function GenPreview: TPreview; |
1284 var x, y, xx, yy, t, bit: LongInt; |
1284 var x, y, xx, yy, t, bit: LongInt; |
1285 Preview: TPreview; |
1285 Preview: TPreview; |
1286 begin |
1286 begin |
1287 WriteLnToConsole('Generating preview...'); |
1287 WriteLnToConsole('Generating preview...'); |
1288 case cMapGen of |
1288 case cMapGen of |
1289 0: GenBlank(EdgeTemplates[SelectTemplate]); |
1289 0: GenBlank(EdgeTemplates[SelectTemplate]); |
1290 1: GenMaze; |
1290 1: GenMaze; |
1291 end; |
1291 end; |
1292 |
1292 |
1293 for y:= 0 to 127 do |
1293 for y:= 0 to 127 do |
1294 for x:= 0 to 31 do |
1294 for x:= 0 to 31 do |
1295 begin |
1295 begin |
1296 Preview[y, x]:= 0; |
1296 Preview[y, x]:= 0; |
1297 for bit:= 0 to 7 do |
1297 for bit:= 0 to 7 do |
1298 begin |
1298 begin |
1299 t:= 0; |
1299 t:= 0; |
1300 for yy:= y * (LAND_HEIGHT div 128) to y * (LAND_HEIGHT div 128) + 7 do |
1300 for yy:= y * (LAND_HEIGHT div 128) to y * (LAND_HEIGHT div 128) + 7 do |
1301 for xx:= x * (LAND_WIDTH div 32) + bit * 8 to x * (LAND_WIDTH div 32) + bit * 8 + 7 do |
1301 for xx:= x * (LAND_WIDTH div 32) + bit * 8 to x * (LAND_WIDTH div 32) + bit * 8 + 7 do |
1302 if Land[yy, xx] <> 0 then inc(t); |
1302 if Land[yy, xx] <> 0 then inc(t); |
1303 if t > 8 then Preview[y, x]:= Preview[y, x] or ($80 shr bit) |
1303 if t > 8 then |
1304 end |
1304 Preview[y, x]:= Preview[y, x] or ($80 shr bit); |
|
1305 end; |
1305 end; |
1306 end; |
1306 GenPreview:= Preview |
1307 |
|
1308 GenPreview:= Preview |
1307 end; |
1309 end; |
1308 |
1310 |
1309 procedure initModule; |
1311 procedure initModule; |
1310 begin |
1312 begin |
1311 LandBackSurface:= nil; |
1313 LandBackSurface:= nil; |