Delay testing mode slightly for flavor text
This commit is contained in:
parent
e0ea72f800
commit
2b714e2cc8
84
game.js
84
game.js
@ -1,4 +1,18 @@
|
|||||||
var canvas;
|
var canvas;
|
||||||
|
|
||||||
|
const GOODQUOTES=[
|
||||||
|
"Let the conversion begin...",
|
||||||
|
"All the bots, come to ME",
|
||||||
|
"Let's convert them ALL",
|
||||||
|
"What a fantastic machine you have built",
|
||||||
|
"I like it!",]
|
||||||
|
const BADQUOTES=[
|
||||||
|
"I smell a funny one here...",
|
||||||
|
"I have found a flaw!",
|
||||||
|
"How could you build me so disfunctionally?",
|
||||||
|
"???",
|
||||||
|
"You seemed to miss a step...",]
|
||||||
|
|
||||||
const WAITING = 0;
|
const WAITING = 0;
|
||||||
const RUNNING = 1;
|
const RUNNING = 1;
|
||||||
const REVIEWING = 2;
|
const REVIEWING = 2;
|
||||||
@ -6,6 +20,8 @@ const TESTING = 3;
|
|||||||
const FINISH = 4;
|
const FINISH = 4;
|
||||||
const PAUSED = 5;
|
const PAUSED = 5;
|
||||||
|
|
||||||
|
var ISTESTING = false;
|
||||||
|
|
||||||
const UP = 0;
|
const UP = 0;
|
||||||
const RIGHT = 1;
|
const RIGHT = 1;
|
||||||
const DOWN = 2;
|
const DOWN = 2;
|
||||||
@ -128,24 +144,31 @@ var MENU = {
|
|||||||
function runGameSimulation(){
|
function runGameSimulation(){
|
||||||
if (gameState!==PAUSED) {
|
if (gameState!==PAUSED) {
|
||||||
gameState=TESTING
|
gameState=TESTING
|
||||||
|
ISTESTING=true
|
||||||
|
BOT_PREVX=-100
|
||||||
|
BOT_PREVY=-100
|
||||||
generateBotQueue()
|
generateBotQueue()
|
||||||
//console.log(BOT_QUEUE)
|
//console.log(BOT_QUEUE)
|
||||||
if (BOT_QUEUE.length>0) {
|
setTimeout(()=>{
|
||||||
BOT_TAPE=BOT_QUEUE[0]
|
ISTESTING=false
|
||||||
} else {
|
if (BOT_QUEUE.length>0) {
|
||||||
BOT_TAPE="BR"
|
BOT_TAPE=BOT_QUEUE[0]
|
||||||
}
|
} else {
|
||||||
BOT_STATE=ALIVE
|
BOT_TAPE="BR"
|
||||||
gameState=WAITING
|
}
|
||||||
BOT_X=gameStage.start.x
|
BOT_X=gameStage.start.x
|
||||||
BOT_Y=gameStage.start.y
|
BOT_Y=gameStage.start.y
|
||||||
BOT_PREVX=BOT_X
|
BOT_PREVX=BOT_X
|
||||||
BOT_PREVY=BOT_Y
|
BOT_PREVY=BOT_Y
|
||||||
BOT_DIR=RIGHT
|
BOT_STATE=ALIVE
|
||||||
gameState=RUNNING
|
gameState=WAITING
|
||||||
if (gameSpeed===-1) {
|
BOT_DIR=RIGHT
|
||||||
gameSpeed=1000/1
|
gameState=RUNNING
|
||||||
}
|
if (gameSpeed===-1) {
|
||||||
|
gameSpeed=1000/1
|
||||||
|
}
|
||||||
|
gameState=RUNNING
|
||||||
|
},300)
|
||||||
}
|
}
|
||||||
gameState=RUNNING
|
gameState=RUNNING
|
||||||
for (var i=0;i<MENU.buttons.length;i++) {
|
for (var i=0;i<MENU.buttons.length;i++) {
|
||||||
@ -166,16 +189,18 @@ function endARound() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pauseGameSimulation(){
|
function pauseGameSimulation(){
|
||||||
gameState=PAUSED
|
if (!ISTESTING) {
|
||||||
endARound()
|
gameState=PAUSED
|
||||||
|
endARound()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function resetSimulation(){
|
function resetSimulation(){
|
||||||
BOT_STATE=ALIVE
|
BOT_STATE=ALIVE
|
||||||
gameState=WAITING
|
gameState=WAITING
|
||||||
BOT_X=gameStage.start.x
|
BOT_X=gameStage.start.x
|
||||||
BOT_Y=gameStage.start.y
|
BOT_Y=gameStage.start.y
|
||||||
BOT_PREVX=BOT_X
|
BOT_PREVX=-100
|
||||||
BOT_PREVY=BOT_Y
|
BOT_PREVY=-100
|
||||||
BOT_DIR=RIGHT
|
BOT_DIR=RIGHT
|
||||||
endARound()
|
endARound()
|
||||||
}
|
}
|
||||||
@ -351,8 +376,10 @@ function ConvertNumberToTape(val) {
|
|||||||
function setNextSquare(offsetX,offsetY) {
|
function setNextSquare(offsetX,offsetY) {
|
||||||
if (gameGrid[BOT_Y+offsetY]!==undefined) {
|
if (gameGrid[BOT_Y+offsetY]!==undefined) {
|
||||||
var nextSquare = gameGrid[BOT_Y+offsetY][BOT_X+offsetX];
|
var nextSquare = gameGrid[BOT_Y+offsetY][BOT_X+offsetX];
|
||||||
BOT_PREVX=BOT_X
|
if (!ISTESTING) {
|
||||||
BOT_PREVY=BOT_Y
|
BOT_PREVX=BOT_X
|
||||||
|
BOT_PREVY=BOT_Y
|
||||||
|
}
|
||||||
LASTPOSITIONUPDATE=new Date().getTime()
|
LASTPOSITIONUPDATE=new Date().getTime()
|
||||||
BOT_X+=offsetX
|
BOT_X+=offsetX
|
||||||
BOT_Y+=offsetY
|
BOT_Y+=offsetY
|
||||||
@ -360,6 +387,7 @@ function setNextSquare(offsetX,offsetY) {
|
|||||||
} else {
|
} else {
|
||||||
gameState = REVIEWING
|
gameState = REVIEWING
|
||||||
BOT_STATE = DEAD
|
BOT_STATE = DEAD
|
||||||
|
endARound()
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -630,7 +658,7 @@ function deepCopy(arr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function step() {
|
function step() {
|
||||||
dashOffset+=0.3
|
dashOffset+=0.1*Math.max((1000/gameSpeed),1)
|
||||||
if (gameState===RUNNING) {
|
if (gameState===RUNNING) {
|
||||||
runBot()
|
runBot()
|
||||||
}
|
}
|
||||||
@ -872,6 +900,16 @@ function RenderGameInfo(ctx) {
|
|||||||
|
|
||||||
RenderTape(canvas.width*0.75+8,16,canvas.width*0.25-16,ctx)
|
RenderTape(canvas.width*0.75+8,16,canvas.width*0.25-16,ctx)
|
||||||
|
|
||||||
|
if (ISTESTING) {
|
||||||
|
ctx.font="32px 'Zilla Slab', serif"
|
||||||
|
ctx.fillStyle="white"
|
||||||
|
ctx.textAlign = "center"
|
||||||
|
ctx.fillText("Testing...",(canvas.width*0.75)/2,canvas.height*0.75)
|
||||||
|
ctx.lineWidth=2
|
||||||
|
ctx.strokeStyle="Black"
|
||||||
|
ctx.strokeText("Testing...",(canvas.width*0.75)/2,canvas.height*0.75)
|
||||||
|
}
|
||||||
|
|
||||||
if (MOBILE) {
|
if (MOBILE) {
|
||||||
drawImage(canvas.width-96+24,canvas.height-96+32,
|
drawImage(canvas.width-96+24,canvas.height-96+32,
|
||||||
IMAGE_OUTLINE,ctx,0)
|
IMAGE_OUTLINE,ctx,0)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<head>
|
<head>
|
||||||
</head>
|
</head>
|
||||||
<body style="background-color:gray;cursor:url('cursor.png') 8 8,auto;">
|
<body style="@import url('https://fonts.googleapis.com/css2?family=Zilla+Slab:wght@400;700&display=swap');
|
||||||
|
background-color:gray;cursor:url('cursor.png') 8 8,auto;">
|
||||||
<center>
|
<center>
|
||||||
<div id="game" style="width:100%"></div>
|
<div id="game" style="width:100%"></div>
|
||||||
</center>
|
</center>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user