+important:
+- second place losing message fix
+
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)
FPS: 30,
WAIT_TIME: 60000, // 1 minute
MAX_GAMES: 2, // the most games allowed to go on at once, to be tweaked as needed for purposes
- ROBO_TIME: 30, // time in seconds before filling out with robots
+ ROBO_TIME: 10, // time in seconds before filling out with robots
// gamestate
DYING_TIME_IN_FRAMES: 100,
BOARD_RADIUS: 10,
ctx.fillText("server is too busy now", 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 drawWin = function(ctx) {
ctx.fillText("WINNER!", 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 draw2nd = function(ctx) {
ctx.restore();
}
+var drawmsg = function(msg) {
+ clearCanvas(ctx);
+ ctx.save();
+ ctx.setTransform(10, 0, 0, 10, ctx.canvas.width/2, ctx.canvas.height/2);
+ ctx.fillStyle = 'rgba(0,225,0,100)';
+ ctx.textAlign = 'center';
+ ctx.fillText(msg.toString(), 0, 0);
+ ctx.restore();
+}
+
var clearCanvas = function(ctx) {
ctx.save();
ctx.clearRect(-ctx.canvas.width, -ctx.canvas.height, ctx.canvas.width*2, ctx.canvas.height*2);
var touchy = evt.touches[0].clientY; // should be guaranteed to be nonempty i think
var cvheight = document.getElementById("c").clientHeight;
if(touchy > cvheight/2) { // may need to swap these if i'm hastily misunderstanding coordinates
- keystate = 'd';
- input = 'd';
- }
- else {
keystate = 'u';
input = 'u';
}
+ else {
+ keystate = 'd';
+ input = 'd';
+ }
}
-const prefixurl = "ws://localhost:6789";
+const prefixurl = "ws://" + window.location.hostname + ":6789";
var theSocket = null;
document.onkeydown = function(e) {keypressHandler(e, true);};
document.onkeyup = function(e) {keypressHandler(e, false);};
- document.addEventListener('touchstart', function(e) {touchhandler(e, true);});
- document.addEventListener('touchstart', function(e) {touchhandler(e, false);});
+ canvas.addEventListener('touchstart', function(e) {touchHandler(e, true);});
+ canvas.addEventListener('touchend', function(e) {touchHandler(e, false);});
var interval = setInterval(function(){keySender(theSocket);}, c.MS_PER_FRAME);
theSocket.onclose = function(e) {clearInterval(interval)};
}
-
window.addEventListener("DOMContentLoaded", e => main());