From: Elijah Cohen Date: Tue, 14 May 2019 22:01:32 +0000 (-0500) Subject: fixt the ending message bug X-Git-Url: https://git.eli173.com/?a=commitdiff_plain;h=03f4d84ecdbb89e58e69a8b61bfb96ca4dba8824;p=pong_br fixt the ending message bug --- diff --git a/TODO.org b/TODO.org index 2317191..19fdde6 100644 --- a/TODO.org +++ b/TODO.org @@ -1,5 +1,4 @@ important: -- second place losing message fix list of things i should still do: - fix collisions diff --git a/web/main.js b/web/main.js index a3f5729..822b920 100644 --- a/web/main.js +++ b/web/main.js @@ -4,6 +4,7 @@ const prefixurl = "ws://" + window.location.hostname + ":6789"; var theSocket = null; var is_dead = false; +var place = 0; var module = {}; @@ -60,11 +61,18 @@ var main = function() { // starts everything, gets us going, setup ish else if(e.data == "l") { document.onclick = function(e) {location.reload()} // okay, outside of 'input' file... document.onkeydown = function(e) {if(e.keyCode == '71') location.reload()}; - draw2nd(ctx); + if(place==0) + drawOverlay(ctx,2); //second place + else + drawOverlay(ctx, place); console.log("loser"); return; } var state = JSON.parse(e.data); + // check for placement, the related order of ops is kinda messy and ad-hoc + if(state.dead.some(d => d.id == state.id)) { + place = state.dead.find(d => d.id == state.id).place; + } if(!is_dead) { // check for deadness