-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.js.map
1 lines (1 loc) · 56.2 KB
/
bundle.js.map
1
{"version":3,"sources":["webpack:///webpack/bootstrap f0f2cb65f414221f3d0b","webpack:///./js/food.js","webpack:///./js/app.js","webpack:///./js/playerGame.js","webpack:///./js/snake.js","webpack:///./js/aiGame.js","webpack:///./js/snakeAI.js"],"names":["Food","unitSize","foodPos","ctx","foodRadius","beginPath","arc","x","y","Math","PI","fillStyle","fill","strokeStyle","lineWidth","stroke","closePath","img","Image","src","that","onload","pattern","createPattern","fillRect","snake","i","length","canvasWidth","canvasHeight","randomX","floor","random","randomY","validFood","human","ai","count","winner","gameRun","countDown","initTime","total","timeText","document","getElementById","innerHTML","game","gameForPlayer","gameForAI","time","clearInterval","result","getElementsByClassName","classList","contains","add","score","okButton","addEventListener","reload","location","speed","startButton","startGame","disabled","setInterval","PlayerGame","snakeCanvas","getContext","gameViewHeight","height","gameViewWidth","width","keyUpHandler","bind","keyDownHandler","init","direction","rightPressed","leftPressed","upPressed","downPressed","food","drawRandomFood","snakeArr","font","fillText","clearRect","bodyCollisionCheck","headX","headY","pop","drawFood","drawSnake","drawScore","reverse","snakeMovement","eat","e","keyCode","Snake","initSnake","unshift","rect","drawAUnitSquare","newHead","AIGame","wallCollisionCheck","move","pos","dir","step","bodyAtRight","wallRight","bodyAtBottom","wallBottom","bodyAtTop","wallTop","bodyAtLeft","wallLeft"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;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AFD,MAEO,IAAI,CAAC,KAAKgB,WAAL,CAAiB9B,IAAjB,CAAD,IAA2B,CAAC,KAAK+B,SAAL,EAAhC,EAAkD;AACvD,mBAAKjB,aAAL,CAAmB,OAAnB;AACD,aAFM,MAEA,IAAI,CAAC,KAAKkB,YAAL,CAAkBhC,IAAlB,CAAD,IAA4B,CAAC,KAAKiC,UAAL,EAAjC,EAAoD;AACzD,mBAAKnB,aAAL,CAAmB,MAAnB;AACD;AACF;AACF;AACF;AACF;;AAED;;;;wBACId,I,EAAM;AACR;AACA;AACA,UAAG,KAAKO,KAAL,KAAeP,KAAKjF,OAAL,CAAaK,CAA5B,IAAiC,KAAKoF,KAAL,KAAeR,KAAKjF,OAAL,CAAaM,CAAhE,EAAmE;AACjE,YAAIkG,UAAU,EAACnG,GAAG,KAAKmF,KAAT,EAAgBlF,GAAG,KAAKmF,KAAxB,EAAd;AACA,aAAKN,QAAL,CAAckB,OAAd,CAAsBG,OAAtB;AACA,aAAKI,GAAL,CAASP,OAAT,CAAiB,CAAC,KAAKb,KAAN,EAAa,KAAKC,KAAlB,CAAjB;AACA,eAAO,IAAP;AACD,OALD,MAKO;AACP;AACE,aAAKN,QAAL,CAAcO,GAAd;AACA,aAAKkB,GAAL,CAASlB,GAAT;AACA,aAAKP,QAAL,CAAckB,OAAd,CAAsB,EAAChG,GAAG,KAAKmF,KAAT,EAAgBlF,GAAG,KAAKmF,KAAxB,EAAtB;AACA,aAAKmB,GAAL,CAASP,OAAT,CAAiB,CAAC,KAAKb,KAAN,EAAa,KAAKC,KAAlB,CAAjB;AACA,eAAO,KAAP;AACD;AACD;AACD;;;;;;kBAGYU,K","file":"bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap f0f2cb65f414221f3d0b","class Food {\n constructor() {\n this.unitSize = 20;\n this.foodPos;\n }\n\n drawFood(ctx) {\n const foodRadius = this.unitSize / 2;\n ctx.beginPath();\n // make it circle, can change later\n ctx.arc(this.foodPos.x * this.unitSize + this.unitSize/2 , this.foodPos.y * this.unitSize + this.unitSize/2, foodRadius, 0, Math.PI*2);\n // ctx.fillStyle = \"#3D9728\";\n // ctx.fillStyle = \"#f1f1f1\";\n ctx.fillStyle = \"#9FE6AC\";\n ctx.fill();\n\n // ctx.strokeStyle = \"#FFF\";\n ctx.strokeStyle = \"#808080\";\n ctx.lineWidth=3;\n ctx.stroke();\n\n ctx.closePath();\n }\n\n drawfoodPic(ctx) {\n const img = new Image();\n img.src = 'p1.jpg';\n // img = ctx.drawImage(img, 0, 0, this.unitSize, this.unitSize);\n const that = this;\n img.onload = function() {\n var pattern = ctx.createPattern(img, '');\n ctx.fillStyle = pattern;\n ctx.fillRect(that.foodPos.x * that.unitSize, that.foodPos.y * that.unitSize, that.unitSize, that.unitSize);\n };\n }\n\n validFood(snake, x, y) {\n for(let i = 0; i < snake.length; i++) {\n if(snake[i].x === x || snake[i].y === y || (snake[i].x === x && snake[i].y === y)) {\n return false;\n }\n }\n\n return true;\n }\n\n drawRandomFood(canvasWidth, canvasHeight, snake) {\n let randomX = Math.floor( Math.random() * (canvasWidth / this.unitSize - 1));\n let randomY = Math.floor( Math.random() * (canvasHeight / this.unitSize - 1));\n // debugger\n //make sure food is not generated at snake's position\n while(!this.validFood(snake, randomX, randomY)) {\n randomX = Math.floor( Math.random() * (canvasWidth / this.unitSize -1));\n randomY = Math.floor( Math.random() * (canvasHeight / this.unitSize -1));\n }\n // for(let i = 0; i < snake.length; i++) {\n // if (snake[i].x === randomX || snake[i].y === randomY || snake[i].x === randomX && snake[i].y === randomY) {\n // randomX = Math.floor( Math.random() * (canvasWidth / this.unitSize));\n // randomY = Math.floor( Math.random() * (canvasHeight / this.unitSize));\n // }\n // }\n\n this.foodPos = {x: randomX, y: randomY};\n }\n}\n\nexport default Food;\n\n\n\n// WEBPACK FOOTER //\n// ./js/food.js","import PlayerGame from './playerGame';\nimport AIGame from './aiGame';\n\nlet human = new PlayerGame();\nlet ai = new AIGame();\nlet count = 0;\nlet winner;\nlet gameRun;\n\nfunction countDown(initTime, total) {\n let timeText = document.getElementById(\"timer\");\n // let initTime = 10;\n timeText.innerHTML = `TIME LEFT: ${total-initTime}`;\n // debugger\n\n}\n\nfunction game() {\n human.gameForPlayer();\n ai.gameForAI();\n // debugger\n\n // timer here, 10000 ms = 10s\n // console.log(count);\n // setInterval(time, 10000);\n // setTimeout(time, 0);\n // console.log(`After: ${count}`);\n // every 10 count as 1s\n // 910 ~ 1 min\n if(count % 15 === 0) {\n countDown(count / 15, Math.floor(910/15));\n }\n time();\n // 460 for 30s\n // 45\n if(count === 910) {\n // document.location.reload();\n // this would stop the game, isntead of reload\n clearInterval(gameRun);\n let result = document.getElementsByClassName(\"result-area\");\n for(let i = 0; i < result.length; i++) {\n if(!result[i].classList.contains(\"is-open\")) {\n result[i].classList.add(\"is-open\");\n }\n }\n\n if(human.score > ai.score) {\n winner = \"YOW WIN\";\n } else if(human.score < ai.score) {\n winner = \"YOU LOSE\";\n } else {\n winner = \"TIED\";\n }\n\n // result[0].innerHTML = `<p>${winner}</p>\n // <p>YOUR SCORE: ${human.score} POINTS</p>\n // <p>AI SCORE: ${ai.score} POINTS</p>\n // <button id=\"reset-button\">OK</button>`;\n result[0].innerHTML = `<p>${winner}</p>\n <p>${human.score} POINTS : ${ai.score} POINTS</p>\n <button id=\"reset-button\">OK</button>`;\n\n const okButton = document.getElementById(\"reset-button\");\n okButton.addEventListener(\"click\", reload);\n\n // alert(`You score ${human.score} points vs AI: ${ai.score} points!`);\n }\n}\n\nfunction reload() {\n document.location.reload();\n}\n\nfunction time() {\n // console.log(count);\n count++;\n}\n\nconst speed = 100;\nconst startButton = document.getElementById(\"start-button\");\nstartButton.addEventListener(\"click\", startGame);\n\nfunction startGame() {\n count = 0;\n // countDown(10);\n startButton.disabled = true;\n gameRun = setInterval(game, 80);\n\n}\n\n\n\n// WEBPACK FOOTER //\n// ./js/app.js","import Snake from './snake';\nimport Food from './food';\n\nclass PlayerGame {\n\n constructor() {\n this.snakeCanvas = document.getElementById(\"human-game-canvas\");\n this.ctx = this.snakeCanvas.getContext(\"2d\");\n\n this.gameViewHeight = this.snakeCanvas.height;\n this.gameViewWidth = this.snakeCanvas.width;\n\n this.score = 0;\n this.speed = 100;\n // document.addEventListener(\"keydown\", this.keyDownHandler, false);\n // document.addEventListener(\"keyup\", this.keyUpHandler, false);\n // this.direction = \"down\";\n // this.rightPressed = false;\n // this.leftPressed = false;\n // this.upPressed = false;\n // this.downPressed = false;\n //\n // this.snake = new Snake();\n // this.food = new Food();\n // this.food.drawRandomFood(this.gameViewWidth, this.gameViewHeight, this.snake);\n\n // need to bind eventhandler\n this.keyUpHandler = this.keyUpHandler.bind(this);\n this.keyDownHandler = this.keyDownHandler.bind(this);\n this.init();\n }\n\n // init direction\n init() {\n this.direction = \"down\";\n this.rightPressed = false;\n this.leftPressed = false;\n this.upPressed = false;\n this.downPressed = false;\n\n this.snake = new Snake();\n this.food = new Food();\n this.food.drawRandomFood(this.gameViewWidth, this.gameViewHeight, this.snake);\n }\n\n // check wall collision\n wallCollisionCheck(x, y) {\n // debugger;\n if(x === -1 || y === -1 || (x === this.gameViewWidth / this.snake.unitSize) || (y === this.gameViewHeight / this.snake.unitSize)) {\n return true;\n } else {\n return false;\n }\n }\n\n willTouchWall(x, y) {\n if(x === 0 || y === 0 || (x === this.gameViewWidth / this.snake.unitSize - 1) || (y === this.gameViewHeight / this.snake.unitSize -1)) {\n return true;\n } else {\n return false;\n }\n // debugger\n }\n\n // check body collision\n bodyCollisionCheck(x, y) {\n for (let i = 1; i < this.snake.snakeArr.length; i++) {\n if(this.snake.snakeArr[i].x === x && this.snake.snakeArr[i].y === y) {\n return true;\n }\n }\n\n return false;\n }\n\n drawScore() {\n this.ctx.beginPath();\n this.ctx.font = \"16px classic-font\";\n // this.ctx.fillStyle = \"#0095DD\";\n this.ctx.fillStyle = \"#fff\";\n this.ctx.fillText(\"YOUR SCORE: \" + this.score, 8, 20);\n this.ctx.closePath();\n }\n\n gameForPlayer() {\n document.addEventListener(\"keydown\", this.keyDownHandler, false);\n document.addEventListener(\"keyup\", this.keyUpHandler, false);\n // clear the screen;\n this.ctx.clearRect(0, 0, this.snakeCanvas.width, this.snakeCanvas.height);\n\n // collision check\n // if (this.bodyCollisionCheck(this.snake.headX, this.snake.headY) || this.wallCollisionCheck(this.snake.headX, this.snake.headY)) {\n if (this.bodyCollisionCheck(this.snake.headX, this.snake.headY)) {\n // debugger;\n // comment this back later\n // alert(\"GAME OVER\");\n // document.location.reload();\n if(this.score > 0) {\n this.score--;\n }\n this.snake.snakeArr.pop();\n }\n\n this.food.drawFood(this.ctx);\n // food.drawfoodPic(ctx);\n this.snake.drawSnake(this.ctx);\n this.drawScore();\n\n // debugger\n if(this.rightPressed) {\n // debugger\n if (this.direction !== \"left\" && this.direction !== \"right\" && (this.snake.headX < this.gameViewWidth / this.snake.unitSize - 1)) {\n this.direction = \"right\";\n }\n } else if (this.leftPressed) {\n if (this.direction !== \"right\" && this.direction !== \"left\" && this.snake.headX > 0) {\n this.direction = \"left\";\n }\n } else if (this.upPressed) {\n if (this.direction !== \"down\" && this.direction !== \"up\" && this.snake.headY > 0) {\n this.direction = \"up\";\n }\n } else if (this.downPressed) {\n if (this.direction !== \"up\" && this.direction !== \"down\" && (this.snake.headY < this.gameViewHeight / this.snake.unitSize - 1)) {\n this.direction = \"down\";\n }\n } else {\n // this is when snake hit the wall:\n // turn around if no key is pressed\n if(this.direction === \"right\" && this.snake.headX >= this.gameViewWidth / this.snake.unitSize - 1) {\n this.direction = \"left\";\n this.snake.snakeArr = this.snake.snakeArr.reverse();\n this.snake.headX = this.snake.snakeArr[0].x;\n this.snake.headY = this.snake.snakeArr[0].y;\n if(this.score > 0) {\n this.score--;\n }\n this.snake.snakeArr.pop();\n } else if(this.direction === \"up\" && this.snake.headY <= 0) {\n this.direction = \"down\";\n this.snake.snakeArr = this.snake.snakeArr.reverse();\n this.snake.headX = this.snake.snakeArr[0].x;\n this.snake.headY = this.snake.snakeArr[0].y;\n if(this.score > 0) {\n this.score--;\n }\n this.snake.snakeArr.pop();\n } else if(this.direction === \"down\" && this.snake.headY >= this.gameViewHeight / this.snake.unitSize - 1) {\n // debugger\n this.direction = \"up\";\n this.snake.snakeArr = this.snake.snakeArr.reverse();\n this.snake.headX = this.snake.snakeArr[0].x;\n this.snake.headY = this.snake.snakeArr[0].y;\n if(this.score > 0) {\n this.score--;\n }\n this.snake.snakeArr.pop();\n } else if(this.direction === \"left\" && this.snake.headX <= 0) {\n // debugger\n this.direction = \"right\";\n this.snake.snakeArr = this.snake.snakeArr.reverse();\n this.snake.headX = this.snake.snakeArr[0].x;\n this.snake.headY = this.snake.snakeArr[0].y;\n if(this.score > 0) {\n this.score--;\n }\n this.snake.snakeArr.pop();\n }\n }\n\n this.snake.snakeMovement(this.direction);\n if (this.snake.eat(this.food)) {\n this.score++;\n // this.speed -= 5;\n this.food.drawRandomFood(this.gameViewWidth, this.gameViewHeight, this.snake);\n }\n\n }\n\n // x === 0 || y === 0 || (x === this.gameViewWidth / this.snake.unitSize - 1) || (y === this.gameViewHeight / this.snake.unitSize -\n // Use a w s d to control\n keyDownHandler(e) {\n // debugger\n if(e.keyCode === 68 && this.direction !== \"right\" && this.snake.headX !== (this.gameViewWidth / this.snake.unitSize - 1)) {\n // debugger\n this.rightPressed = true;\n } else if(e.keyCode === 65 && this.direction !== \"left\") {\n this.leftPressed = true;\n } else if(e.keyCode === 87 && this.direction !== \"up\") {\n this.upPressed = true;\n } else if(e.keyCode === 83 && this.direction !== \"down\") {\n this.downPressed = true;\n }\n // debugger\n }\n\n keyUpHandler(e) {\n if(e.keyCode === 68) {\n this.rightPressed = false;\n } else if(e.keyCode === 65) {\n this.leftPressed = false;\n } else if(e.keyCode === 87) {\n this.upPressed = false;\n } else if(e.keyCode === 83) {\n this.downPressed = false;\n }\n }\n\n\n\n}\n\nexport default PlayerGame;\n\n\n\n// WEBPACK FOOTER //\n// ./js/playerGame.js","class Snake {\n constructor() {\n this.snakeArr = [];\n this.unitSize = 20;\n this.headX = 0;\n this.headY = 0;\n this.initSnake();\n }\n\n initSnake() {\n let length = 5;\n for(let i = 0; i < length; i++) {\n // snake head at index 0\n this.snakeArr.unshift({x: i, y: 0});\n }\n this.headX = this.snakeArr[0].x;\n this.headY = this.snakeArr[0].y;\n // debugger;\n }\n\n drawAUnitSquare(ctx, x, y) {\n ctx.beginPath();\n ctx.rect(x * this.unitSize, y * this.unitSize, this.unitSize, this.unitSize);\n // ctx.fillStyle = \"#F5FA30\";\n // ctx.fillStyle = \"#000\";\n // ctx.fillStyle = \"#585858\";\n ctx.fillStyle = \"#315BCB\";\n\n ctx.fill();\n // border\n // ctx.strokeStyle = \"red\";\n ctx.strokeStyle = \"#FFF\";\n ctx.lineWidth=3;\n ctx.stroke();\n ctx.closePath();\n }\n\n // draw snake body (build up by unit square)\n drawSnake(ctx) {\n for(let i = 0; i < this.snakeArr.length; i++) {\n this.drawAUnitSquare(ctx, this.snakeArr[i].x, this.snakeArr[i].y);\n }\n }\n\n snakeMovement(direction) {\n // update the head to get the new head\n switch (direction) {\n case \"up\":\n this.headY--;\n break;\n case \"down\":\n this.headY++;\n break;\n case \"left\":\n this.headX--;\n break;\n case \"right\":\n this.headX++;\n break;\n // default:\n // this.headX = this.headX;\n // this.headY = this.headY;\n // break;\n }\n }\n\n // does snake eat?\n eat(food) {\n // new head after updating headX & headY\n if(this.headX === food.foodPos.x && this.headY === food.foodPos.y) {\n let newHead = {x: this.headX, y: this.headY};\n this.snakeArr.unshift(newHead);\n return true;\n } else {\n // unshift new head to snakeArr\n this.snakeArr.pop();\n this.snakeArr.unshift({x: this.headX, y: this.headY});\n return false;\n }\n // debugger\n }\n\n}\nexport default Snake;\n\n\n\n// WEBPACK FOOTER //\n// ./js/snake.js","import Snake from './snakeAI';\nimport Food from './food';\n\nclass AIGame {\n constructor() {\n this.snakeCanvas = document.getElementById(\"ai-game-canvas\");\n this.ctx = this.snakeCanvas.getContext(\"2d\");\n\n this.gameViewHeight = this.snakeCanvas.height;\n this.gameViewWidth = this.snakeCanvas.width;\n\n this.score = 0;\n this.speed = 100;\n this.init();\n }\n // init direction\n init() {\n this.direction = \"down\";\n this.rightPressed = false;\n this.leftPressed = false;\n this.upPressed = false;\n this.downPressed = false;\n\n this.snake = new Snake();\n this.food = new Food();\n this.food.drawRandomFood(this.gameViewWidth, this.gameViewHeight, this.snake);\n }\n // check wall collision\n wallCollisionCheck(x, y) {\n // debugger;\n if(x === -1 || y === -1 || (x === this.gameViewWidth / this.snake.unitSize) || (y === this.gameViewHeight / this.snake.unitSize)) {\n return true;\n } else {\n return false;\n }\n }\n\n willTouchWall(x, y) {\n if(x === 0 || y === 0 || (x === this.gameViewWidth / this.snake.unitSize - 1) || (y === this.gameViewHeight / this.snake.unitSize -1)) {\n return true;\n } else {\n return false;\n }\n // debugger\n }\n\n // check body collision\n bodyCollisionCheck(x, y) {\n for (let i = 1; i < this.snake.snakeArr.length; i++) {\n if(this.snake.snakeArr[i].x === x && this.snake.snakeArr[i].y === y) {\n return true;\n }\n }\n\n return false;\n }\n\n drawScore() {\n this.ctx.beginPath();\n this.ctx.font = \"16px classic-font\";\n // this.ctx.fillStyle = \"#0095DD\";\n this.ctx.fillStyle = \"#fff\";\n this.ctx.fillText(\"AI SCORE: \" + this.score, 8, 20);\n this.ctx.closePath();\n }\n\n gameForAI() {\n // clear the screen;\n this.ctx.clearRect(0, 0, this.snakeCanvas.width, this.snakeCanvas.height);\n // food.drawFood(ctx, 24, 0);\n\n // collision check\n if (this.bodyCollisionCheck(this.snake.headX, this.snake.headY) || this.wallCollisionCheck(this.snake.headX, this.snake.headY)) {\n // debugger;\n // comment this back later\n // alert(\"GAME OVER\");\n //\n // document.location.reload();\n if(this.score > 0) {\n // this.score--;\n this.score -= 2;\n }\n this.snake.snakeArr.pop();\n this.snake.snakeArr.pop();\n }\n\n this.food.drawFood(this.ctx);\n // food.drawfoodPic(ctx);\n this.snake.drawSnake(this.ctx);\n this.drawScore();\n // Need to implement here\n // snake.snakeMovement(direction);\n this.snake.move(this.food);\n if (this.snake.eat(this.food)) {\n this.score++;\n // this.speed -= 5;\n // let randomWidthX = gameViewWidth / (Math.floor( Math.random() * 4 + 1));\n // let randomHeightY = gameViewWidth / (Math.floor( Math.random() * 4 + 1));\n this.food.drawRandomFood(this.gameViewWidth, this.gameViewWidth, this.snake);\n }\n\n }\n}\n\nexport default AIGame;\n\n\n\n// WEBPACK FOOTER //\n// ./js/aiGame.js","class Snake {\n constructor() {\n this.snakeArr = [];\n this.unitSize = 20;\n this.headX = 0;\n this.headY = 0;\n this.pos = [];\n this.initSnake();\n this.dir = \"down\";\n }\n\n initSnake() {\n let length = 5;\n for(let i = 0; i < length; i++) {\n // snake head at index 0\n this.snakeArr.unshift({x: i, y: 0});\n // init pos\n this.pos.unshift([i, 0]);\n }\n this.headX = this.snakeArr[0].x;\n this.headY = this.snakeArr[0].y;\n // debugger;\n }\n\n drawAUnitSquare(ctx, x, y) {\n ctx.beginPath();\n ctx.rect(x * this.unitSize, y * this.unitSize, this.unitSize, this.unitSize);\n // ctx.fillStyle = \"#F5FA30\";\n // ctx.fillStyle = \"#000\";\n // ctx.fillStyle = \"#585858\";\n ctx.fillStyle = \"#C33D2C\";\n ctx.fill();\n // border\n // ctx.strokeStyle = \"red\";\n ctx.strokeStyle = \"#FFF\";\n ctx.lineWidth=3;\n ctx.stroke();\n ctx.closePath();\n }\n\n // draw snake body (build up by unit square)\n drawSnake(ctx) {\n for(let i = 0; i < this.snakeArr.length; i++) {\n this.drawAUnitSquare(ctx, this.snakeArr[i].x, this.snakeArr[i].y);\n }\n }\n\n snakeMovement(direction, step=1) {\n // update the head to get the new head\n this.dir = direction;\n switch (direction) {\n case \"up\":\n this.headY -= step;\n break;\n case \"down\":\n this.headY += step;\n break;\n case \"left\":\n this.headX -= step;\n break;\n case \"right\":\n this.headX += step;\n break;\n // default:\n // this.headX = this.headX;\n // this.headY = this.headY;\n // break;\n }\n }\n\n wallRight() {\n return this.headX === 24;\n }\n wallLeft() {\n return this.headX === 0;\n }\n wallTop() {\n return this.headY === 0;\n }\n wallBottom() {\n return this.headY === 24;\n }\n\n\n\n // check if body at right\n bodyAtRight(food) {\n // debugger\n for (let i = 1; i < this.snakeArr.length; i++) {\n // check body right\n if(this.snakeArr[i].x <= food.foodPos.x && this.snakeArr[i].x >= this.headX) {\n // if(this.snakeArr[i].x <= food.foodPos.x && this.snakeArr[i].x === this.headX+1) {\n // if(this.snakeArr[i].x >= this.headX) {\n if(this.snakeArr[i].y === this.headY) {\n // debugger\n return true;\n }\n }\n }\n return false;\n }\n\n // check if body at left\n bodyAtLeft(food) {\n // debugger\n for (let i = 1; i < this.snakeArr.length; i++) {\n // check body left\n if(this.snakeArr[i].x >= food.foodPos.x && this.snakeArr[i].x <= this.headX) {\n // if(this.snakeArr[i].x >= food.foodPos.x && this.snakeArr[i].x === this.headX-1) {\n // if(this.snakeArr[i].x <= this.headX) {\n if(this.snakeArr[i].y === this.headY) {\n return true;\n }\n }\n }\n return false;\n }\n\n // check if body at top\n bodyAtTop(food) {\n // debugger\n for (let i = 1; i < this.snakeArr.length; i++) {\n // check body top\n if(this.snakeArr[i].y >= food.foodPos.y && this.snakeArr[i].y <= this.headY) {\n // if(this.snakeArr[i].y >= food.foodPos.y && this.snakeArr[i].y === this.headY-1) {\n // if(this.snakeArr[i].y <= this.headY) {\n if(this.snakeArr[i].x === this.headX) {\n return true;\n }\n }\n }\n return false;\n }\n\n // check if body at bottom\n bodyAtBottom(food) {\n // debugger\n for (let i = 1; i < this.snakeArr.length; i++) {\n // check body bottom\n if(this.snakeArr[i].y <= food.foodPos.y && this.snakeArr[i].y >= this.headY) {\n // if(this.snakeArr[i].y <= food.foodPos.y && this.snakeArr[i].y === this.headY+1) {\n // if(this.snakeArr[i].y >= this.headY) {\n if(this.snakeArr[i].x === this.headX) {\n return true;\n }\n }\n }\n return false;\n }\n\n bounceBack() {\n\n }\n\n // move for AI\n move(food) {\n if(food.foodPos.x > this.headX) { // food at right\n // debugger\n // moving right\n if(this.dir === \"right\") {\n if(!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n } else if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n } else if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n }\n } else if(this.dir === \"left\") { // moving left\n if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n } else if (!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");\n } else if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n }\n } else if (this.dir === \"up\") { // moving up\n if (!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n } else if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n } else if (!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");\n }\n } else if (this.dir === \"down\") { // moving down\n if (!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n } else if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n } else if (!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");\n }\n }\n // } else {\n // this.snakeMovement(\"down\");\n // }\n } else if(food.foodPos.x < this.headX) { // food at left\n // debugger\n // moving left\n if(this.dir === \"left\") {\n if(!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");\n } else if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n } else if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n }\n } else if(this.dir === \"right\") { // moving right\n if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n } else if (!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n } else if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n }\n } else if (this.dir === \"up\") { // moving up\n if (!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");//33\n } else if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n } else if (!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n }\n } else if (this.dir === \"down\") { // moving down\n if (!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");\n } else if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n } else if (!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n }\n }\n\n } else if(food.foodPos.x === this.headX) {// food at the same x\n if(food.foodPos.y > this.headY) { // food at bottom\n\n if (this.dir === \"down\") { // moving down\n if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n } else if (!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n } else if (!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");\n }\n } else if(this.dir === \"up\") { // moving up\n if (!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");\n } else if (!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n } else if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n }\n } if(this.dir === \"left\") { // moving left\n if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n } else if(!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");\n } else if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n }\n } else if(this.dir === \"right\") { // moving right\n if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n } else if (!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n } else if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n }\n }\n\n } else { // food at top if(food.foodPos.y <= this.headY)\n\n if(this.dir === \"up\") { //moving up\n if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n } else if (!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n } else if (!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");\n }\n } else if (this.dir === \"down\") { // moving down\n if (!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");\n } else if (!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n } else if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n }\n } else if(this.dir === \"left\") { // moving left\n if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n } else if(!this.bodyAtLeft(food) && !this.wallLeft()) {\n this.snakeMovement(\"left\");\n } else if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n }\n } else if(this.dir === \"right\") { // moving right\n if (!this.bodyAtTop(food) && !this.wallTop()) {\n this.snakeMovement(\"up\");\n } else if (!this.bodyAtRight(food) && !this.wallRight()) {\n this.snakeMovement(\"right\");\n } else if (!this.bodyAtBottom(food) && !this.wallBottom()) {\n this.snakeMovement(\"down\");\n }\n }\n }\n }\n }\n\n // does snake eat?\n eat(food) {\n // this.move(food);\n // new head after updating headX & headY\n if(this.headX === food.foodPos.x && this.headY === food.foodPos.y) {\n let newHead = {x: this.headX, y: this.headY};\n this.snakeArr.unshift(newHead);\n this.pos.unshift([this.headX, this.headY]);\n return true;\n } else {\n // unshift new head to snakeArr\n this.snakeArr.pop();\n this.pos.pop();\n this.snakeArr.unshift({x: this.headX, y: this.headY});\n this.pos.unshift([this.headX, this.headY]);\n return false;\n }\n // debugger\n }\n\n}\nexport default Snake;\n\n\n\n// WEBPACK FOOTER //\n// ./js/snakeAI.js"],"sourceRoot":""}