X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/copy_structured?a=blobdiff_plain;f=new2%2Frogue_chat_nocanvas_monochrome.html;h=d873b3761d658d5daae3b7ee7ce45cd4b630b9c4;hb=90d7e8cdc98943e46ec9a3d8d2debf2886f793e2;hp=97c0f0879d8176baacf145a454b3fa6cb1b6b31c;hpb=61c63e6df3cc5bbd22fdbf3036481ade88112ca4;p=plomrogue2-experiments diff --git a/new2/rogue_chat_nocanvas_monochrome.html b/new2/rogue_chat_nocanvas_monochrome.html index 97c0f08..d873b37 100644 --- a/new2/rogue_chat_nocanvas_monochrome.html +++ b/new2/rogue_chat_nocanvas_monochrome.html @@ -44,12 +44,15 @@ let terminal = { drawBox: function(start_y, start_x, height, width) { let end_y = start_y + height; let end_x = start_x + width; - for (let y = start_y, x = start_x; y < end_y; x++) { - this.content[y][x] = ' '; + for (let y = start_y, x = start_x;; x++) { if (x == end_x) { - x = start_x - 1; - y += 1; - } + x = start_x; + y += 1; + if (y == end_y) { + break; + } + }; + this.content[y][x] = ' '; } }, } @@ -124,7 +127,9 @@ let tui = { for (const thing_id in game.things) { let t = game.things[thing_id]; map_lines[t[0]][t[1]] = '@'; - player_position = t; + if (game.player_id == thing_id) { + player_position = t; + } } let offset = [(terminal.rows / 2) - player_position[0], terminal.cols / 4 - player_position[1]]; @@ -171,7 +176,8 @@ let game = { things: {}, turn: 0, map: "", - map_size: [0,0] + map_size: [0,0], + player_id: 0 } let chat = { @@ -220,6 +226,8 @@ websocket.onmessage = function (event) { } else if (tokens[0] === 'LOG') { tui.log_msg(tokens[1], 1); tui.refresh(); + } else if (tokens[0] === 'PLAYER_ID') { + game.player_id = parseInt(tokens[1]); } else if (tokens[0] === 'META') { tui.log_msg(tokens[1]); tui.refresh();