34 hasGirders: boolean; |
34 hasGirders: boolean; |
35 isMap: boolean; |
35 isMap: boolean; |
36 playHeight, playWidth, leftX, rightX, topY, MaxHedgehogs: Longword; // idea is that a template can specify height/width. Or, a map, a height/width by the dimensions of the image. If the map has pixels near top of image, it triggers border. |
36 playHeight, playWidth, leftX, rightX, topY, MaxHedgehogs: Longword; // idea is that a template can specify height/width. Or, a map, a height/width by the dimensions of the image. If the map has pixels near top of image, it triggers border. |
37 LandBackSurface: PSDL_Surface; |
37 LandBackSurface: PSDL_Surface; |
38 |
38 |
39 type direction = record x, y: Longint; end; |
39 type direction = record x, y: LongInt; end; |
40 const DIR_N: direction = (x: 0; y: -1); |
40 const DIR_N: direction = (x: 0; y: -1); |
41 DIR_E: direction = (x: 1; y: 0); |
41 DIR_E: direction = (x: 1; y: 0); |
42 DIR_S: direction = (x: 0; y: 1); |
42 DIR_S: direction = (x: 0; y: 1); |
43 DIR_W: direction = (x: -1; y: 0); |
43 DIR_W: direction = (x: -1; y: 0); |
44 |
44 |
650 const small_cell_size = 128; |
650 const small_cell_size = 128; |
651 medium_cell_size = 192; |
651 medium_cell_size = 192; |
652 large_cell_size = 256; |
652 large_cell_size = 256; |
653 braidness = 10; |
653 braidness = 10; |
654 |
654 |
655 var x, y: Longint; |
655 var x, y: LongInt; |
656 cellsize: LongInt; //selected by the user in the gui |
656 cellsize: LongInt; //selected by the user in the gui |
657 seen_cells_x, seen_cells_y: Longint; //number of cells that can be visited by the generator, that is every second cell in x and y direction. the cells between there are walls that will be removed when we move from one cell to another |
657 seen_cells_x, seen_cells_y: LongInt; //number of cells that can be visited by the generator, that is every second cell in x and y direction. the cells between there are walls that will be removed when we move from one cell to another |
658 num_edges_x, num_edges_y: Longint; //number of resulting edges that need to be vertexificated |
658 num_edges_x, num_edges_y: LongInt; //number of resulting edges that need to be vertexificated |
659 num_cells_x, num_cells_y: Longint; //actual number of cells, depending on cell size |
659 num_cells_x, num_cells_y: LongInt; //actual number of cells, depending on cell size |
660 seen_list: array of array of Longint; |
660 seen_list: array of array of LongInt; |
661 xwalls: array of array of Boolean; |
661 xwalls: array of array of Boolean; |
662 ywalls: array of array of Boolean; |
662 ywalls: array of array of Boolean; |
663 x_edge_list: array of array of Boolean; |
663 x_edge_list: array of array of Boolean; |
664 y_edge_list: array of array of Boolean; |
664 y_edge_list: array of array of Boolean; |
665 maze: array of array of Boolean; |
665 maze: array of array of Boolean; |
666 pa: TPixAr; |
666 pa: TPixAr; |
667 num_vertices: Longint; |
667 num_vertices: LongInt; |
668 off_y: LongInt; |
668 off_y: LongInt; |
669 num_steps: Longint; |
669 num_steps: LongInt; |
670 current_step: Longint; |
670 current_step: LongInt; |
671 step_done: array of Boolean; |
671 step_done: array of Boolean; |
672 done: Boolean; |
672 done: Boolean; |
673 last_cell: array of record x, y: Longint; end; |
673 last_cell: array of record x, y: LongInt; end; |
674 came_from: array of array of record x, y: Longint; end; |
674 came_from: array of array of record x, y: LongInt; end; |
675 came_from_pos: array of Longint; |
675 came_from_pos: array of LongInt; |
676 maze_inverted: Boolean; |
676 maze_inverted: Boolean; |
677 |
677 |
678 function when_seen(x: Longint; y: Longint): Longint; |
678 function when_seen(x: LongInt; y: LongInt): LongInt; |
679 begin |
679 begin |
680 if (x < 0) or (x >= seen_cells_x) or (y < 0) or (y >= seen_cells_y) then |
680 if (x < 0) or (x >= seen_cells_x) or (y < 0) or (y >= seen_cells_y) then |
681 when_seen := current_step |
681 when_seen := current_step |
682 else |
682 else |
683 when_seen := seen_list[x, y]; |
683 when_seen := seen_list[x, y]; |
684 end; |
684 end; |
685 |
685 |
686 function is_x_edge(x, y: Longint): Boolean; |
686 function is_x_edge(x, y: LongInt): Boolean; |
687 begin |
687 begin |
688 if (x < 0) or (x > num_edges_x) or (y < 0) or (y > num_cells_y) then |
688 if (x < 0) or (x > num_edges_x) or (y < 0) or (y > num_cells_y) then |
689 is_x_edge := false |
689 is_x_edge := false |
690 else |
690 else |
691 is_x_edge := x_edge_list[x, y]; |
691 is_x_edge := x_edge_list[x, y]; |
692 end; |
692 end; |
693 |
693 |
694 function is_y_edge(x, y: Longint): Boolean; |
694 function is_y_edge(x, y: LongInt): Boolean; |
695 begin |
695 begin |
696 if (x < 0) or (x > num_cells_x) or (y < 0) or (y > num_edges_y) then |
696 if (x < 0) or (x > num_cells_x) or (y < 0) or (y > num_edges_y) then |
697 is_y_edge := false |
697 is_y_edge := false |
698 else |
698 else |
699 is_y_edge := y_edge_list[x, y]; |
699 is_y_edge := y_edge_list[x, y]; |
700 end; |
700 end; |
701 |
701 |
702 procedure see_cell; |
702 procedure see_cell; |
703 var dir: direction; |
703 var dir: direction; |
704 tries: Longint; |
704 tries: LongInt; |
705 x, y: Longint; |
705 x, y: LongInt; |
706 found_cell: Boolean; |
706 found_cell: Boolean; |
707 next_dir_clockwise: Boolean; |
707 next_dir_clockwise: Boolean; |
708 |
708 |
709 begin |
709 begin |
710 x := last_cell[current_step].x; |
710 x := last_cell[current_step].x; |