- let offset = [(terminal.rows / 2) - center_pos[0],
- this.window_width / 2 - center_pos[1]];
- for (let term_y = offset[0], map_y = 0;
- term_y < terminal.rows && map_y < game.map_size[0];
- term_y++, map_y++) {
- if (term_y >= 0) {
- let to_draw = map_lines[map_y].join('').slice(0, this.window_width - offset[1]);
- terminal.write(term_y, offset[1], to_draw);
- }
+ let map_lines = []
+ if (game.map_geometry == 'Square') {
+ for (let line_split of map_lines_split) {
+ map_lines.push(line_split.join(''));
+ };
+ } else if (game.map_geometry == 'Hex') {
+ let indent = 0
+ for (let line_split of map_lines_split) {
+ map_lines.push(' '.repeat(indent) + line_split.join(' '));
+ if (indent == 0) {
+ indent = 1;
+ } else {
+ indent = 0;
+ };
+ };
+ }
+ let window_center = [terminal.rows / 2, this.window_width / 2];
+ let player = game.things[game.player_id];
+ let center_position = [player.position[0], player.position[1]];
+ if (tui.mode.shows_info) {
+ center_position = [explorer.position[0], explorer.position[1]];
+ }
+ if (game.map_geometry == 'Hex') {
+ center_position[1] = center_position[1] * 2;
+ };
+ let offset = [center_position[0] - window_center[0],
+ center_position[1] - window_center[1]]
+ if (game.map_geometry == 'Hex' && offset[0] % 2) {
+ offset[1] += 1;
+ };
+ let term_y = Math.max(0, -offset[0]);
+ let term_x = Math.max(0, -offset[1]);
+ let map_y = Math.max(0, offset[0]);
+ let map_x = Math.max(0, offset[1]);
+ for (; term_y < terminal.rows && map_y < game.map_size[0]; term_y++, map_y++) {
+ let to_draw = map_lines[map_y].slice(map_x, this.window_width + offset[1]);
+ terminal.write(term_y, term_x, to_draw);