X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;ds=sidebyside;f=new2%2Frogue_chat_nocanvas_monochrome.html;h=754021f6ead49f6f6f4d5ad3aa010c26ab35a701;hb=021e4276cce114de08c0ce3c5e781ffc2184d4ee;hp=de0aa6a598327cdca463d900576251e4b60d45e9;hpb=790a8101d22234587704f658aaaa0220019e93c0;p=plomrogue2-experiments diff --git a/new2/rogue_chat_nocanvas_monochrome.html b/new2/rogue_chat_nocanvas_monochrome.html index de0aa6a..754021f 100644 --- a/new2/rogue_chat_nocanvas_monochrome.html +++ b/new2/rogue_chat_nocanvas_monochrome.html @@ -17,12 +17,16 @@ cols: "use strict"; let websocket_location = "ws://localhost:8000"; +let wasd_selector = document.getElementById("WASD_selector"); +let rows_selector = document.getElementById("n_rows"); +let cols_selector = document.getElementById("n_cols"); + let terminal = { - rows: 24, - cols: 80, foreground: 'white', background: 'black', initialize: function() { + this.rows = rows_selector.value; + this.cols = cols_selector.value; this.pre_el = document.getElementById("terminal"); this.pre_el.style.color = this.foreground; this.pre_el.style.backgroundColor = this.background; @@ -77,6 +81,7 @@ let terminal = { } }, } +terminal.initialize(); let parser = { tokenize: function(str) { @@ -195,17 +200,27 @@ let tui = { height_turn_line: 1, height_mode_line: 1, height_input: 1, - key_up: 'w', - key_down: 's', - key_left: 'a', - key_right: 'd', - movement_keys_desc: 'w, a, s, d', init: function() { this.inputEl = document.getElementById("input"); this.inputEl.focus(); this.recalc_input_lines(); this.height_header = this.height_turn_line + this.height_mode_line; this.log_msg("@ waiting for server connection ..."); + this.init_wasd(); + }, + init_wasd: function() { + if (wasd_selector.value == 'w, a, s, d') { + tui.key_up = 'w'; + tui.key_down = 's'; + tui.key_left = 'a'; + tui.key_right = 'd'; + } else if (wasd_selector.value == 'arrow keys') { + tui.key_up = 'ArrowUp'; + tui.key_down = 'ArrowDown'; + tui.key_left = 'ArrowLeft'; + tui.key_right = 'ArrowRight'; + }; + tui.movement_keys_desc = wasd_selector.value; }, init_login: function() { this.log_msg("@ please enter your username:"); @@ -371,10 +386,9 @@ let game = { turn: 0, map: "", map_size: [0,0], - player_id: 0 + player_id: -1 } -terminal.initialize(); tui.init(); tui.full_refresh(); @@ -575,30 +589,14 @@ tui.inputEl.addEventListener('keydown', (event) => { } }, false); -let wasd_selector = document.getElementById("WASD_selector"); wasd_selector.addEventListener('input', function() { - if (wasd_selector.value == 'w, a, s, d') { - tui.key_up = 'w'; - tui.key_down = 's'; - tui.key_left = 'a'; - tui.key_right = 'd'; - } else if (wasd_selector.value == 'arrow keys') { - tui.key_up = 'ArrowUp'; - tui.key_down = 'ArrowDown'; - tui.key_left = 'ArrowLeft'; - tui.key_right = 'ArrowRight'; - }; - tui.movement_keys_desc = wasd_selector.value; + tui.init_wasd(); }, false); -let rows_selector = document.getElementById("n_rows"); rows_selector.addEventListener('input', function() { - terminal.rows = rows_selector.value; terminal.initialize(); tui.full_refresh(); }, false); -let cols_selector = document.getElementById("n_cols"); cols_selector.addEventListener('input', function() { - terminal.cols = cols_selector.value; terminal.initialize(); tui.window_width = terminal.cols / 2, tui.full_refresh();