Fix the pause button

master
sigonasr2 4 years ago
parent 9b6169f2f1
commit e0ea72f800
  1. 8
      game.js

@ -126,6 +126,7 @@ var MENU = {
} }
function runGameSimulation(){ function runGameSimulation(){
if (gameState!==PAUSED) {
gameState=TESTING gameState=TESTING
generateBotQueue() generateBotQueue()
//console.log(BOT_QUEUE) //console.log(BOT_QUEUE)
@ -142,6 +143,11 @@ function runGameSimulation(){
BOT_PREVY=BOT_Y BOT_PREVY=BOT_Y
BOT_DIR=RIGHT BOT_DIR=RIGHT
gameState=RUNNING gameState=RUNNING
if (gameSpeed===-1) {
gameSpeed=1000/1
}
}
gameState=RUNNING
for (var i=0;i<MENU.buttons.length;i++) { for (var i=0;i<MENU.buttons.length;i++) {
if (MENU.buttons[i].img===IMAGE_PLAY) { if (MENU.buttons[i].img===IMAGE_PLAY) {
MENU.buttons[i]=PAUSE_BUTTON MENU.buttons[i]=PAUSE_BUTTON
@ -690,7 +696,7 @@ function renderGame(ctx) {
drawImage(GRID_X+GRID_W*gameStage.start.x+16+GRID_W/2, drawImage(GRID_X+GRID_W*gameStage.start.x+16+GRID_W/2,
GRID_Y+GRID_H*gameStage.start.y+16+GRID_H/2, GRID_Y+GRID_H*gameStage.start.y+16+GRID_H/2,
IMAGE_ENTRANCE,ctx,0) IMAGE_ENTRANCE,ctx,0)
if (BOT_X!==undefined&&(gameState===RUNNING||gameState==REVIEWING||gameState==FINISH)) { if (BOT_X!==undefined&&(gameState===RUNNING||gameState===PAUSED||gameState==REVIEWING||gameState==FINISH)) {
var movedDiff = {x:BOT_X-BOT_PREVX,y:BOT_Y-BOT_PREVY} var movedDiff = {x:BOT_X-BOT_PREVX,y:BOT_Y-BOT_PREVY}
movedDiff.x*=Math.min((new Date().getTime()-LASTPOSITIONUPDATE),gameSpeed)/gameSpeed movedDiff.x*=Math.min((new Date().getTime()-LASTPOSITIONUPDATE),gameSpeed)/gameSpeed
movedDiff.y*=Math.min((new Date().getTime()-LASTPOSITIONUPDATE),gameSpeed)/gameSpeed movedDiff.y*=Math.min((new Date().getTime()-LASTPOSITIONUPDATE),gameSpeed)/gameSpeed

Loading…
Cancel
Save