]> git.eli173.com Git - pong_br/commitdiff
fixt the ending message bug
authorElijah Cohen <eli@eli173.com>
Tue, 14 May 2019 22:01:32 +0000 (17:01 -0500)
committerElijah Cohen <eli@eli173.com>
Tue, 14 May 2019 22:01:32 +0000 (17:01 -0500)
TODO.org
web/main.js

index 231719124e441988569a2dbef9c7e73e22ba4cc3..19fdde64851008e6021b32df4857332e6833fe04 100644 (file)
--- 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
index a3f572941a93be68ae742b2b904ad3fb8e5eaff8..822b9207263297c26e19ed7a060608a91443a4a1 100644 (file)
@@ -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