]> git.eli173.com Git - pong_br/commitdiff
chores and todo-list items for before poblication
authorElijah Cohen <eli@eli173.com>
Mon, 13 May 2019 20:50:50 +0000 (15:50 -0500)
committerElijah Cohen <eli@eli173.com>
Mon, 13 May 2019 20:50:50 +0000 (15:50 -0500)
TODO.org [new file with mode: 0644]
server/TODO.org
server/game.js
server/player.js
server/robot.js
web/draw.js
web/main.js

diff --git a/TODO.org b/TODO.org
new file mode 100644 (file)
index 0000000..61b33bd
--- /dev/null
+++ b/TODO.org
@@ -0,0 +1,8 @@
+list of things i should still do:
+- fix collisions
+- fix oob
+- splash page
+- fiddle with variables to optimize fun
+- TOUCH
+- fix game not ending with just robots (is this actually broken?)
+- double check all messages for fitting (look to the 'magic number...' comment)
index a4db889214cbb5f7eee7aaabf5ca24c5cbbb2af5..7500669597ca532e9a07bd364d51b5db320049a2 100644 (file)
@@ -1,7 +1,8 @@
 list of things i should still do:
-- death screens
-- waiting message
 - fix collisions
 - fix oob
 - splash page
 - fiddle with variables to optimize fun
+- TOUCH
+- fix game not ending with just robots (is this actually broken?)
+- double check all on-screen messages for fitting (look to the 'magic number...' comment)
index 0e4368177dae8e83f470495442bec0eb1f555d51..e9de5f393f58a5945dc86eb046f5a221f1652953 100644 (file)
@@ -28,6 +28,12 @@ Game.prototype.getNextFrame = function() {
        this.players[i].send_data(state);
     }
 
+    // check for only robots left
+    /*if(!this.players.some(x => !x.isARobot)) { // not true that some player isn't a robot
+       clearInterval(this.timeout);
+       health.dec();
+    }*/
+    
     // check for life and death
     var dead_ids = state.dead.map(d => d.id);
     if(dead_ids.length == state.n-1) {
index ed64f78af2f0554c929ce51f6102d5de7ceef000..0f8a7e251c216d0946c661b21f4fb557469090e5 100644 (file)
@@ -3,6 +3,7 @@
 function Player(ws) {
     this.status = 'x';
     this.socket = ws;
+    this.isARobot = false;
     this.id = -1; // is this used? can i just delete?
     var _this = this;
     var fn = function(msg) {
index 6f1fecfd88817bd2ef6dd727b492e1c624e59223..0c1c35639f379fe3db80786a6543941c0d2c64c5 100644 (file)
@@ -6,6 +6,7 @@ const field = require('./field.js');
 
 function Robot() {
     this.status = 'x';
+    this.isARobot = true;
 }
 
 Robot.prototype.close = function() {
index 0b3ca4d1386e14c0c9e7cb2117c1efdd4c4e29fb..0683686183bc9c18421940e02ca8148da60462bb 100644 (file)
@@ -112,15 +112,50 @@ var drawLine = function(ctx, color, c1, c2) {
 var drawOverlay = function(ctx, place) {
     ctx.save();
     //ctx.font = what should it equal? mind sizes on mobile
-    ctx.setTransform(1,0,0,1,0,0);
+    ctx.setTransform(10, 0, 0, 10, ctx.canvas.width/2, ctx.canvas.height/2);
     ctx.fillStyle = 'rgba(225,225,225,100)'
-    var string1 = "you placed: " + place;
-    var string2 = "click or press =g= to play again"
-    ctx.fillText(string1, 0, 100);
-    ctx.fillText(string2, 0, 200); // magic number...
+    ctx.textAlign = 'center';
+    ctx.fillText("you placed: " + place, 0, -7.5);
+    ctx.fillText("press =g= or click", 0, 0); // magic numbers...
+    ctx.fillText("to play again", 0, 7.5);
     ctx.restore();
 }
-       
+
+var drawWaiting = function(ctx) {
+    ctx.save();
+    ctx.setTransform(10, 0, 0, 10, ctx.canvas.width/2, ctx.canvas.height/2);
+    // i think that the above is unneccesary, but might as well be safe. Not like much is going on client-side
+    ctx.fillStyle = 'rgba(225,225,225,100)';
+    ctx.textAlign = 'center';
+    ctx.fillText("waiting for", 0, -5);
+    ctx.fillText("opponents...", 0, 5);
+    ctx.restore();
+}
+
+var drawOver = function(ctx) {
+    ctx.save();
+    ctx.setTransform(10, 0, 0, 10, ctx.canvas.width/2, ctx.canvas.height/2);
+    ctx.fillStyle = 'rgba(225,225,225,100)'
+    ctx.textAlign = 'center';
+    ctx.fillText("press =g= or click", 0, -5);
+    ctx.fillText("to play again", 0, 5);
+    ctx.restore();
+
+}
+
+var drawBusy = function(ctx) {
+    clearCanvas(ctx);
+    ctx.save();
+    ctx.setTransform(10, 0, 0, 10, ctx.canvas.width/2, ctx.canvas.height/2);
+    // i think that the above is unneccesary, but might as well be safe. Not like much is going on client-side
+    ctx.fillStyle = 'rgba(225,225,225,100)';
+    ctx.textAlign = 'center';
+    ctx.fillText("server is too busy now", 0, -7.5);
+    ctx.fillText("press =g= or click", 0, 0); // magic numbers...
+    ctx.fillText("to play again", 0, 7.5);
+    ctx.restore();
+    
+}
 
 var clearCanvas = function(ctx) {
     ctx.save();
index e9de70536335dcaf99baab4de97fc3f7a08165f8..3b6b4658b6a7d7e90100e90f88a4600b85dfa67b 100644 (file)
@@ -17,21 +17,27 @@ var main = function() { // starts everything, gets us going, setup ish
     canvas.height = window.innerHeight;
     ctx = canvas.getContext('2d');
     // i need to modify the 10's here to be appropriate given the scaling of the window
-    ctx.setTransform(10, 0, 0, 10, ctx.canvas.width/2, ctx.canvas.height/2); // change to setTransform?
+    ctx.setTransform(10, 0, 0, 10, ctx.canvas.width/2, ctx.canvas.height/2);
     ctx.lineWidth = ctx.lineWidth/5;
 
     
-    // this is just to have everything go easily for testing
+    // this is just to have everything go easily for testing, delete before final
+    /**
     var othersockets = [];
     for(var i=0; i<c.NUM_PLAYERS -1; i++) {
        othersockets.push(new WebSocket(prefixurl));
     }
-
+    /**/
     
     theSocket = new WebSocket(prefixurl);
+    drawWaiting(ctx);
+    
     theSocket.onmessage = function(e) {
        if(e.data == "busy") {
-           onBusy();
+           canvas.onclick = function(e) {location.reload()} // okay, outside of 'input' file...
+           canvas.onkeydown = function(e) {if(e.keyCode == '71') location.reload()};
+           drawBusy(ctx);
+           // socket should be closed by server
            return;
        }
        canvas.width = window.innerWidth;
@@ -70,8 +76,5 @@ var main = function() { // starts everything, gets us going, setup ish
     theSocket.onclose = function(e) {clearInterval(interval)};
 }
 
-var onBusy = function() {
-    console.log("busy, try again later");
-}
 
 window.addEventListener("DOMContentLoaded", e => main());