From c47d37f7a44babae5ff3b91423db5c007f7fc378 Mon Sep 17 00:00:00 2001 From: "Glitch (hello-express)" Date: Wed, 11 Mar 2020 19:54:22 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=95=8D=E2=8F=B1=20Checkpoint=20./server.j?= =?UTF-8?q?s:9949330/1025?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 60 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/server.js b/server.js index 3dbfaad..c8de9c3 100644 --- a/server.js +++ b/server.js @@ -27,6 +27,8 @@ function chat(string) { var ctoggle = true; +var cursormode = "dvd"; + client.on("a", (msg) => { let args = msg.a.split(' '); let cmd = args[0].toLowerCase(); @@ -34,9 +36,25 @@ client.on("a", (msg) => { switch (cmd) { case "dvd!help": - chat("not finished :)"); + chat("cmds: dvd!help // dvd!cursor"); + break; + case "dvd!cursor": + if (!argcat || argcat == "") { + chat("Modes: on // off"); + } else { + switch (argcat) { + case "on": + ctoggle = true; + pos = {x: 5, y: 5}; + cursormode = "dvd"; + break; + case "off": + ctoggle = false; + cursormode = "none"; + break; + } + } break; - case "dvd!cursor" } }); @@ -47,24 +65,30 @@ var cursor = setInterval(function() { if (ctoggle == true) { client.sendArray([{m:'m', x: client.getOwnParticipant().x = pos.x + 50, y: client.getOwnParticipant().y = pos.y + 50}]) } else { - pos.x = 200; - pos.y = 200; + pos.x = -150; + pos.y = -150; } }); var cursorupdate = setInterval(function() { - pos.x += vel.x; - pos.y += vel.y; - if (pos.x >= 50) { - vel.x = -vel.x; - } - if (pos.y >= 50) { - vel.y = -vel.y; - } - if (pos.x <= -50) { - vel.x = -vel.x; - } - if (pos.y <= -50) { - vel.y = -vel.y; - } + switch (cursormode) { + case "dvd": + pos.x += vel.x; + pos.y += vel.y; + if (pos.x >= 50) { + vel.x = -vel.x; + } + if (pos.y >= 50) { + vel.y = -vel.y; + } + if (pos.x <= -50) { + vel.x = -vel.x; + } + if (pos.y <= -50) { + vel.y = -vel.y; + } + break; + case "off": + + } }, 25); \ No newline at end of file