// 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
}
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() {
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) {
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)) {