From 9b6169f2f1e7d38c1a01772a3f2356f677e6479b Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Wed, 2 Sep 2020 11:27:39 +0900 Subject: [PATCH] Implement simulation speed control --- game.js | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 100 insertions(+), 4 deletions(-) diff --git a/game.js b/game.js index 37a7eff..dd3edba 100644 --- a/game.js +++ b/game.js @@ -32,6 +32,7 @@ var BOT_TAPE = "RB" var BOT_QUEUE = [] var DELETEMODE = false var DRAGGING = false +var MOUSEDOWN = false var DRAG_X = -1 var DRAG_Y = -1 @@ -359,7 +360,7 @@ function setNextSquare(offsetX,offsetY) { function runBot(testing) { //console.log(new Date().getTime()) - if (lastGameUpdate=x&&LAST_MOUSE_X<=x+w && LAST_MOUSE_Y>=y-6&&LAST_MOUSE_Y<=y+6) { + var mouseCursorPos = Math.round((LAST_MOUSE_X-x)/8)*8 + switch (mouseCursorPos) { + case 0:{ + gameSpeed=-1; + }break; + case 8:{ + gameSpeed=1000/1; + }break; + case 16:{ + gameSpeed=1000/2; + }break; + case 24:{ + gameSpeed=1000/3; + }break; + case 32:{ + gameSpeed=1000/4; + }break; + case 40:{ + gameSpeed=1000/6; + }break; + case 48:{ + gameSpeed=1000/8; + }break; + case 56:{ + gameSpeed=1000/16; + }break; + case 64:{ + gameSpeed=1000/32; + }break; + } + } + ctx.beginPath() + ctx.moveTo(x+cursorX,y-4) + ctx.lineTo(x+cursorX,y+4) + ctx.stroke(); +} + function RenderGameInfo(ctx) { if (MENU.visible) { ctx.fillStyle="#20424a" ctx.fillRect(canvas.width*0.75,0,canvas.width,canvas.height*0.8) - RenderTape(canvas.width*0.75+8,8,canvas.width*0.25-16,ctx) + + RenderSpeedbar(canvas.width*0.75+(canvas.width*0.25)/2-32,8,64,ctx) + + RenderTape(canvas.width*0.75+8,16,canvas.width*0.25-16,ctx) if (MOBILE) { drawImage(canvas.width-96+24,canvas.height-96+32,