From 570f6cac7cb9662e275a64422287e33da415bee0 Mon Sep 17 00:00:00 2001 From: Elijah Cohen Date: Fri, 17 May 2019 20:44:55 -0500 Subject: [PATCH] added starting message, paddle speed boost --- server/constants.js | 2 +- server/game.js | 9 ++++++++- web/draw.js | 12 +++++++++++- web/main.js | 3 +++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/server/constants.js b/server/constants.js index d42b8df..8b57aad 100644 --- a/server/constants.js +++ b/server/constants.js @@ -23,7 +23,7 @@ var c = { // field BOARD_RADIUS: 10, // completely arbitrary actually... // paddle - DPADDLE: 0.1, + DPADDLE: 0.2, WIDTH_RATIO: 0.2, // paddle is 1/10th of gap rn } diff --git a/server/game.js b/server/game.js index e9de5f3..cce24a3 100644 --- a/server/game.js +++ b/server/game.js @@ -15,7 +15,14 @@ function Game(players) { Game.prototype.start = function(ms) { var _this = this; var tmpfn = function() {_this.getNextFrame()}; - this.timeout = setInterval(tmpfn, ms); + var tmpfn2 = function() {_this.setInt(tmpfn, ms);}; + setTimeout(tmpfn2, 3000); + for(var player of players) { + player.send_data('starting'); + } +} +Game.prototype.setInt = function(fn, ms) { + this.timeout = setInterval(fn, ms); } Game.prototype.getNextFrame = function() { diff --git a/web/draw.js b/web/draw.js index 5566443..94374d2 100644 --- a/web/draw.js +++ b/web/draw.js @@ -186,7 +186,17 @@ var draw2nd = function(ctx) { ctx.fillText("second place!", 0, -7.5); ctx.fillText("press =g= or click/tap", 0, 0); // magic numbers... ctx.fillText("to play again", 0, 7.5); - ctx.restore(); + ctx.restore(); +} + +var drawStarting = function(ctx) { + clearCanvas(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("starting...", 0, 0); // magic numbers... + ctx.restore(); } var drawmsg = function(msg) { diff --git a/web/main.js b/web/main.js index 1cddc90..0f9db54 100644 --- a/web/main.js +++ b/web/main.js @@ -66,6 +66,9 @@ var main = function() { // starts everything, gets us going, setup ish drawOverlay(ctx, place); return; } + if(e.data == "starting") { + drawStarting(ctx); + } 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)) { -- 2.39.2