How to use fixedBlockSize method in wpt

Best JavaScript code snippet using wpt

Ghost.js

Source:Ghost.js Github

copy

Full Screen

1// var ghosts = [ // COLOR CHARACTER NICKNAME2// blinky, // RED SHADOW BLINKY3// pinky, // PINK SPEEDY PINKY4// inky, // BLUE BASHFUL INKY5// clyde // ORANGE POKEY CLYDE6// ];7import {8 ACTORINITIAL,9 BLOCKSIZE,10 ACTORMODE,11 PENROUTINEPOS,12 GAMEMODE,13 PENEXIT,14} from '../Misc/GameRes'15const Dir2Anim = {16 1: 0,17 2: 1,18 4: 2,19 8: 3,20}21const oppositeDirections = {22 1: 2,23 2: 1,24 4: 8,25 8: 426}27const PM_MOVEMENTS = {28 0: {29 axis: 0,30 increment: 031 },32 4: {//左33 axis: 0,34 increment: -135 },36 8: {//右37 axis: 0,38 increment: +139 },40 1: {//上41 axis: 1,42 increment: -143 },44 2: {//下45 axis: 1,46 increment: +147 }48}49const allDirection = [1, 4, 2, 8];//50const pacmanAnim = [51 14, 15, 16, 17, 18, 19, 20, 21,//red上下左右52 22, 23, 24, 25, 26, 27, 28, 29,//pink53 30, 31, 32, 33, 34, 35, 36, 37,//blue54 38, 39, 40, 41, 42, 43, 44, 45,//yellow55 50, 51, 52, 53,//受惊56 54, 55, 56, 55,//pacman右大 //57 57, 59, 60, 61, 61, 62, 63,//stick //58 68, 69, 70, 71,//眼睛上下左右 //4759];60const FIXEDBIT = 1061const FIXEDCOEFF = 102462const halfBLOCKSIZE = (BLOCKSIZE >> 1);63const fixedBLOCKSIZE = (BLOCKSIZE << FIXEDBIT);64const fixedHalfBLOCKSIZE = (halfBLOCKSIZE << FIXEDBIT);65export default class Ghost {66 constructor(id, mainRef) {67 this.mainRef = mainRef;68 this.id = id;69 }70 resetActor() {71 let init = ACTORINITIAL[this.id];72 this.pos = [];73 this.pos[0] = init.x * BLOCKSIZE + halfBLOCKSIZE;74 this.pos[1] = init.y * BLOCKSIZE + halfBLOCKSIZE;75 this.tilePos = [this.pos[0], this.pos[1]];76 this.targetPos = [init.scatterX * BLOCKSIZE + halfBLOCKSIZE, init.scatterY * BLOCKSIZE + halfBLOCKSIZE];77 this.scatterPos = [init.scatterX * BLOCKSIZE + halfBLOCKSIZE, init.scatterY * BLOCKSIZE + halfBLOCKSIZE];78 this.dir = init.dir;79 this.updateSpeed();80 this.followingRoutine = false;81 this.reverseDirectionsNext = false;82 this.targetPlayerId = 0;83 this.freeToLeavePen = false;84 this.eatenInThisFrightMode = false;85 this.renderMode = ACTORMODE.NONE;86 if (this.id == this.mainRef.playerCount) {87 this.animIdx = 0 + Dir2Anim[this.dir] * 2;88 } else if (this.id == this.mainRef.playerCount + 1) {89 this.animIdx = 8 + Dir2Anim[this.dir] * 2;90 } else if (this.id == this.mainRef.playerCount + 2) {91 this.animIdx = 16 + Dir2Anim[this.dir] * 2;92 } else if (this.id == this.mainRef.playerCount + 3) {93 this.animIdx = 24 + Dir2Anim[this.dir] * 2;94 }95 }96 followRoutine() {97 if (this.routineMoveId == -1 || this.proceedToNextRoutineMove)98 this.switchFollowingRoutine();99 this.continueFollowingRoutine()100 };101 continueFollowingRoutine() {102 var b = PENROUTINEPOS[this.routineToFollow][this.routineMoveId];103 if (b) {104 if (this.speed) {105 switch (this.dir) {106 case 1://上107 this.pos[1] -= this.speed;108 if (this.pos[1] < b.dest * BLOCKSIZE + halfBLOCKSIZE) {109 this.pos[1] = b.dest * BLOCKSIZE + halfBLOCKSIZE;110 this.proceedToNextRoutineMove = true111 }112 break;113 case 4://左114 this.pos[0] -= this.speed;115 if (this.pos[0] < b.dest * BLOCKSIZE + halfBLOCKSIZE) {116 this.pos[0] = b.dest * BLOCKSIZE + halfBLOCKSIZE;117 this.proceedToNextRoutineMove = true118 }119 break;120 case 2://下121 this.pos[1] += this.speed;122 if (this.pos[1] > b.dest * BLOCKSIZE + halfBLOCKSIZE) {123 this.pos[1] = b.dest * BLOCKSIZE + halfBLOCKSIZE;124 this.proceedToNextRoutineMove = true125 }126 break;127 case 8://右128 this.pos[0] += this.speed;129 if (this.pos[0] > b.dest * BLOCKSIZE + halfBLOCKSIZE) {130 this.pos[0] = b.dest * BLOCKSIZE + halfBLOCKSIZE;131 this.proceedToNextRoutineMove = true132 }133 break134 }135 }136 }137 };138 switchFollowingRoutine() {139 this.routineMoveId++;140 if (this.routineMoveId == PENROUTINEPOS[this.routineToFollow].length) {141 if (this.mode == ACTORMODE.IN_PEN && this.freeToLeavePen && this.mainRef.ghostExitingPenNow == false) {142 this.eatenInThisFrightMode ? this.changeActorMode(ACTORMODE.RE_LEAVING_FROM_PEN) : this.changeActorMode(ACTORMODE.LEAVING_PEN);143 return144 } else if (this.mode == ACTORMODE.LEAVING_PEN || this.mode == ACTORMODE.RE_LEAVING_FROM_PEN) {145 this.pos = [PENEXIT[0], PENEXIT[1]];146 this.dir = this.modeChangedWhileInPen ? 8 : 4;147 var m = this.mainRef.mainGhostMode;148 if (this.mode == ACTORMODE.RE_LEAVING_FROM_PEN && m == ACTORMODE.FRIGHTENED)149 m = this.mainRef.lastMainGhostMode;150 this.changeActorMode(m);151 return152 } else if (this.mode == ACTORMODE.ENTERING_PEN) {153 if (this.id == this.mainRef.playerCount || this.freeToLeavePen)154 this.changeActorMode(ACTORMODE.RE_LEAVING_FROM_PEN);155 else {156 this.eatenInThisFrightMode = true;157 this.changeActorMode(ACTORMODE.IN_PEN)158 }159 return160 } else161 this.routineMoveId = 0;162 }163 let b = PENROUTINEPOS[this.routineToFollow][this.routineMoveId];164 this.pos[1] = b.y * BLOCKSIZE + halfBLOCKSIZE;165 this.pos[0] = b.x * BLOCKSIZE + halfBLOCKSIZE;166 this.dir = b.dir;167 this.speed = b.speed * 1.5;168 this.proceedToNextRoutineMove = false;169 };170 changeActorMode(newMode) {171 let oldMode = this.mode;172 this.mode = newMode;173 if (this.id == this.mainRef.playerCount + 3 && (newMode == 16 || oldMode == 16))174 this.mainRef.updateCruiseElroySpeed();175 switch (oldMode) {176 case ACTORMODE.LEAVING_PEN://32:177 this.mainRef.ghostExitingPenNow = false;178 break;179 case ACTORMODE.EATEN://8180 this.mainRef.ghostEyesCount > 0 && this.mainRef.ghostEyesCount--;181 //this.mainRef.ghostEyesCount == 0 && this.mainRef.playAmbientSound();182 break183 }184 switch (newMode) {185 case ACTORMODE.CHASE:186 this.fullSpeed = this.mainRef.levels.ghostSpeed * 0.8;187 this.tunnelSpeed = this.mainRef.levels.ghostTunnelSpeed * 0.8;188 this.followingRoutine = false;189 break;190 case ACTORMODE.SCATTER:191 this.targetPos = this.scatterPos;192 this.fullSpeed = this.mainRef.levels.ghostSpeed * 0.8;193 this.tunnelSpeed = this.mainRef.levels.ghostTunnelSpeed * 0.8;194 this.followingRoutine = false;195 break;196 case ACTORMODE.FRIGHTENED://0b00000100:197 this.fullSpeed = this.mainRef.levels.ghostFrightSpeed * 0.8;198 this.tunnelSpeed = this.mainRef.levels.ghostTunnelSpeed * 0.8;199 this.followingRoutine = false;200 break;201 case ACTORMODE.EATEN: //0b00001000://在围栏(pen)里徘徊202 this.tunnelSpeed = this.fullSpeed = 1.6;203 this.targetPos = [PENEXIT[0], PENEXIT[1]];204 this.freeToLeavePen = this.followingRoutine = false;205 break;206 case ACTORMODE.IN_PEN:207 this.targetPlayerId = 0;208 this.followingRoutine = true;209 this.routineMoveId = -1;210 switch (this.id) {211 case this.mainRef.playerCount + 1:212 this.routineToFollow = 2;213 break;214 case this.mainRef.playerCount + 2:215 this.routineToFollow = 1;216 break;217 case this.mainRef.playerCount + 3:218 this.routineToFollow = 3;219 break220 }221 break;222 case ACTORMODE.LEAVING_PEN://32223 this.followingRoutine = true;224 this.routineMoveId = -1;225 switch (this.id) {226 case this.mainRef.playerCount + 1:227 this.routineToFollow = 5;228 break;229 case this.mainRef.playerCount + 2:230 this.routineToFollow = 4;231 break;232 case this.mainRef.playerCount + 3:233 this.routineToFollow = 6;234 break235 }236 this.mainRef.ghostExitingPenNow = true;237 break;238 case ACTORMODE.ENTERING_PEN://0b01000000://64239 this.followingRoutine = true;240 this.routineMoveId = -1;241 switch (this.id) {242 case this.mainRef.playerCount:243 case this.mainRef.playerCount + 1:244 this.routineToFollow = 8;245 break;246 case this.mainRef.playerCount + 2:247 this.routineToFollow = 7;248 break;249 case this.mainRef.playerCount + 3:250 this.routineToFollow = 9;251 break252 }253 break;254 case ACTORMODE.RE_LEAVING_FROM_PEN://0b10000000://128255 this.followingRoutine = true;256 this.routineMoveId = -1;257 switch (this.id) {258 case this.mainRef.playerCount:259 case this.mainRef.playerCount + 1:260 this.routineToFollow = 11;261 break;262 case this.mainRef.playerCount + 2:263 this.routineToFollow = 10;264 break;265 case this.mainRef.playerCount + 3:266 this.routineToFollow = 12;267 break268 }269 break270 }271 this.updateSpeed();272 }273 move() {274 let mapWidth = (this.mainRef.worldMap.playfieldWidth + 1) * BLOCKSIZE275 let moveDistance = this.speed * 1.5;276 if (this.mode != ACTORMODE.EATEN && Math.round(this.pos[1]) == 14 * BLOCKSIZE + halfBLOCKSIZE &&277 (this.pos[0] < BLOCKSIZE + halfBLOCKSIZE || this.pos[0] > 26 * BLOCKSIZE + halfBLOCKSIZE))278 moveDistance = this.tunnelSpeed * 1.5;279 if (this.reverseDirectionsNext) {280 this.dir = oppositeDirections[this.dir];281 this.reverseDirectionsNext = false;282 }283 moveDistance = Math.round(moveDistance * FIXEDCOEFF);284 if (this.mode == ACTORMODE.EATEN)285 moveDistance = (moveDistance << 1);286 mapWidth = Math.round(mapWidth << FIXEDBIT);287 let fixedPosX = Math.round(this.pos[0] * FIXEDCOEFF);288 let fixedPosY = Math.round(this.pos[1] * FIXEDCOEFF);289 let checkEaten = (this.mode == ACTORMODE.EATEN && fixedPosY == (PENEXIT[1] << FIXEDBIT))290 let oldFixedPosX = fixedPosX;291 while (moveDistance > 0) {292 let blockXX = (fixedPosX < 0 ? (fixedPosX + (fixedBLOCKSIZE << 2)) : fixedPosX) % fixedBLOCKSIZE;293 let blockYY = fixedPosY % fixedBLOCKSIZE;294 if (blockXX != fixedHalfBLOCKSIZE) {//横向295 if (blockXX < fixedHalfBLOCKSIZE) {//在左半边296 if (this.dir == 4) {//往左移动297 let maxDist = blockXX + fixedHalfBLOCKSIZE;298 if (moveDistance >= maxDist) {299 fixedPosX -= maxDist;300 if (fixedPosX < -fixedHalfBLOCKSIZE) fixedPosX += mapWidth + fixedBLOCKSIZE;301 moveDistance -= maxDist;302 }303 else {304 fixedPosX -= moveDistance;305 if (fixedPosX < -fixedHalfBLOCKSIZE) fixedPosX += mapWidth + fixedBLOCKSIZE;306 moveDistance = 0;307 continue;308 }309 }310 else if (this.dir == 8) {//往右移动311 let maxDist = fixedHalfBLOCKSIZE - blockXX;312 if (moveDistance >= maxDist) {313 fixedPosX += maxDist;314 if (fixedPosX > mapWidth + fixedHalfBLOCKSIZE) fixedPosX -= (mapWidth + fixedBLOCKSIZE);315 moveDistance -= maxDist;316 }317 else {318 fixedPosX += moveDistance;319 if (fixedPosX > mapWidth + fixedHalfBLOCKSIZE) fixedPosX -= (mapWidth + fixedBLOCKSIZE);320 moveDistance = 0;321 continue;322 }323 }324 }325 else {//在格子右半边326 if (this.dir == 4) {//往左移动327 let maxDist = blockXX - fixedHalfBLOCKSIZE;328 if (moveDistance >= maxDist) {329 fixedPosX -= maxDist;330 if (fixedPosX < -fixedHalfBLOCKSIZE) fixedPosX += mapWidth + fixedBLOCKSIZE;331 moveDistance -= maxDist;332 }333 else {334 fixedPosX -= moveDistance;335 if (fixedPosX < -fixedHalfBLOCKSIZE) fixedPosX += mapWidth + fixedBLOCKSIZE;336 moveDistance = 0;337 continue;338 }339 }340 else if (this.dir == 8) {//往右移动341 let maxDist = fixedBLOCKSIZE - blockXX + fixedHalfBLOCKSIZE;342 if (moveDistance >= maxDist) {343 fixedPosX += maxDist;344 if (fixedPosX > mapWidth + fixedHalfBLOCKSIZE) fixedPosX -= (mapWidth + fixedBLOCKSIZE);345 moveDistance -= maxDist;346 }347 else {348 fixedPosX += moveDistance;349 if (fixedPosX > mapWidth + fixedHalfBLOCKSIZE) fixedPosX -= (mapWidth + fixedBLOCKSIZE);350 moveDistance = 0;351 continue;352 }353 }354 }355 }356 else if (blockYY != fixedHalfBLOCKSIZE) {//竖向357 if (blockYY < fixedHalfBLOCKSIZE) {//在上半边358 if (this.dir == 1) {//往上移动359 let maxDist = blockYY + fixedHalfBLOCKSIZE;360 if (moveDistance >= maxDist) {361 fixedPosY -= maxDist;362 moveDistance -= maxDist;363 }364 else {365 fixedPosY -= moveDistance;366 moveDistance = 0;367 continue;368 }369 }370 else if (this.dir == 2) {//往下移动371 let maxDist = fixedHalfBLOCKSIZE - blockYY;372 if (moveDistance >= maxDist) {373 fixedPosY += maxDist;374 moveDistance -= maxDist;375 }376 else {377 fixedPosY += moveDistance;378 moveDistance = 0;379 continue;380 }381 }382 }383 else {//在格子下半边384 if (this.dir == 1) {//往上移动385 let maxDist = blockYY - fixedHalfBLOCKSIZE;386 if (moveDistance >= maxDist) {387 fixedPosY -= maxDist;388 moveDistance -= maxDist;389 }390 else {391 fixedPosY -= moveDistance;392 moveDistance = 0;393 continue;394 }395 }396 else if (this.dir == 2) {//往下移动397 let maxDist = fixedBLOCKSIZE - blockYY + fixedHalfBLOCKSIZE;398 if (moveDistance >= maxDist) {399 fixedPosY += maxDist;400 moveDistance -= maxDist;401 }402 else {403 fixedPosY += moveDistance;404 moveDistance = 0;405 continue;406 }407 }408 }409 }410 else {//在中心411 if (this.dir == 1) {//往上移动412 let maxDist = fixedBLOCKSIZE;413 if (moveDistance >= maxDist) {414 fixedPosY -= maxDist;415 moveDistance -= maxDist;416 }417 else {418 fixedPosY -= moveDistance;419 moveDistance = 0;420 continue;421 }422 }423 else if (this.dir == 2) {//往下移动424 let maxDist = fixedBLOCKSIZE;425 if (moveDistance >= maxDist) {426 fixedPosY += maxDist;427 moveDistance -= maxDist;428 }429 else {430 fixedPosY += moveDistance;431 moveDistance = 0;432 continue;433 }434 }435 else if (this.dir == 4) {//往左移动436 let maxDist = fixedBLOCKSIZE;437 if (moveDistance >= maxDist) {438 fixedPosX -= maxDist;439 if (fixedPosX < -fixedHalfBLOCKSIZE) fixedPosX += mapWidth + fixedBLOCKSIZE;440 moveDistance -= maxDist;441 }442 else {443 fixedPosX -= moveDistance;444 if (fixedPosX < -fixedHalfBLOCKSIZE) fixedPosX += mapWidth + fixedBLOCKSIZE;445 moveDistance = 0;446 continue;447 }448 }449 else if (this.dir == 8) {//往右移动 450 let maxDist = fixedBLOCKSIZE;451 if (moveDistance >= maxDist) {452 fixedPosX += maxDist;453 if (fixedPosX > mapWidth + fixedHalfBLOCKSIZE) fixedPosX -= (mapWidth + fixedBLOCKSIZE);454 moveDistance -= maxDist;455 }456 else {457 fixedPosX += moveDistance;458 if (fixedPosX > mapWidth + fixedHalfBLOCKSIZE) fixedPosX -= (mapWidth + fixedBLOCKSIZE);459 moveDistance = 0;460 continue;461 }462 } else break;463 }464 // if (this.mode == ACTORMODE.EATEN &&465 // Math.round(this.pos[0]) == PENEXIT[0] &&466 // Math.round(this.pos[1]) == PENEXIT[1]) {467 // this.changeActorMode(ACTORMODE.ENTERING_PEN);//怪物进门468 // return;469 // }470 //break;471 this.pos[0] = (fixedPosX >> FIXEDBIT);472 this.pos[1] = (fixedPosY >> FIXEDBIT);473 // if (this.mode == ACTORMODE.EATEN){474 // console.log("被吃");475 // }476 this.updateDir();477 }478 this.pos[0] = (fixedPosX / FIXEDCOEFF);479 this.pos[1] = (fixedPosY / FIXEDCOEFF);480 if (checkEaten) {481 let oldPosX = (oldFixedPosX >> FIXEDBIT);482 let newPosX = (fixedPosX >> FIXEDBIT);483 if ((oldPosX >= PENEXIT[0] && newPosX <= PENEXIT[0]) ||484 (newPosX >= PENEXIT[0] && oldPosX <= PENEXIT[0])) {485 this.pos[0] = PENEXIT[0];486 this.changeActorMode(ACTORMODE.ENTERING_PEN);//怪物进门487 return;488 }489 }490 }491 updateDir() {492 var field = this.mainRef.worldMap.playfield[Math.round(this.pos[1]) - halfBLOCKSIZE][Math.round(this.pos[0]) - halfBLOCKSIZE];493 if (field.intersection) {//移动到了交叉路口494 switch (this.mode) {495 case ACTORMODE.SCATTER:496 case ACTORMODE.CHASE:497 case ACTORMODE.EATEN:498 if ((this.dir & field.allowedDir) == 0 && field.allowedDir == oppositeDirections[this.dir]) //死路 需要回头499 this.dir = oppositeDirections[this.dir];500 else {501 let minDist = 99999999999;502 let bestDir = 0;503 for (var k in allDirection) {//从所有可走的方向中找出离目标点最近的方向504 var dir = allDirection[k];505 if (field.allowedDir & dir && this.dir != oppositeDirections[dir]) {506 let temp = PM_MOVEMENTS[dir];507 var x = [this.pos[0], this.pos[1]];508 x[temp.axis] += temp.increment;509 temp = this.mainRef.getDistance(x, [this.targetPos[0], this.targetPos[1]]);510 if (temp < minDist) {511 minDist = temp;512 bestDir = dir513 }514 }515 }516 if (bestDir) this.dir = bestDir517 }518 break;519 case ACTORMODE.FRIGHTENED:520 if ((this.dir & field.allowedDir) == 0 && field.allowedDir == oppositeDirections[this.dir])//死路 需要回头521 this.dir = oppositeDirections[this.dir];522 else {523 let randDir;524 do randDir = allDirection[Math.floor(this.mainRef.rand() * 4)];525 while ((randDir & field.allowedDir) == 0 || randDir == oppositeDirections[this.dir]);526 this.dir = randDir527 }528 break529 }530 }531 }532 ////设置移动目标位置533 updateTargetPos() {534 if (this.id == this.mainRef.playerCount && this.mainRef.dotsRemaining < this.mainRef.levels.elroyDotsLeftPart1 && this.mode == 2 && (!this.mainRef.lostLifeOnThisLevel || this.mainRef.actors[3].mode != 16)) {535 var b = this.mainRef.player;///.actors[this.targetPlayerId];536 this.targetPos = [b.pos[0], b.pos[1]]537 } else if (this.mode == ACTORMODE.CHASE) {538 let player = this.mainRef.player;//this.mainRef.actors[this.targetPlayerId];539 let movement;540 switch (this.id) {541 // Blinky always follows the player.542 case this.mainRef.playerCount:543 this.targetPos = [player.pos[0], player.pos[1]];544 break;545 // Pinky follows a tile ahead of player.546 case this.mainRef.playerCount + 1:547 this.targetPos = [player.pos[0], player.pos[1]];548 movement = PM_MOVEMENTS[player.dir];549 this.targetPos[movement.axis] += 32 * movement.increment;550 // Recreating the original Pac-Man bug, in which UP = UP+LEFT551 if (player.dir == 1)552 this.targetPos[1] -= 4 * BLOCKSIZE;553 break;554 // Inky uses a convoluted scheme averaging Blinky's position and an offset tile.555 case this.mainRef.playerCount + 2:556 let blinky = this.mainRef.actors[0];557 let offsetPos = [player.pos[0], player.pos[1]];558 movement = PM_MOVEMENTS[player.dir];559 offsetPos[movement.axis] += 2 * BLOCKSIZE * movement.increment;560 if (player.dir == 1)561 offsetPos[1] -= 2 * BLOCKSIZE;562 this.targetPos[0] = offsetPos[0] * 2 - blinky.pos[0];563 this.targetPos[1] = offsetPos[1] * 2 - blinky.pos[1];564 break;565 // Clyde uses Pac-Man's position if further away, scatter position if close.566 case this.mainRef.playerCount + 3:567 let distance = this.mainRef.getDistance(player.pos, this.pos);568 this.targetPos = distance > (8 * BLOCKSIZE) ? [player.pos[0], player.pos[1]] : this.scatterPos;569 break570 }571 }572 };573 update() {574 if (this.followingRoutine) {575 this.followRoutine();576 } else {577 //this.step();578 this.move();579 if (this.mode == ACTORMODE.CHASE || this.mode == ACTORMODE.SCATTER || this.mode == ACTORMODE.FRIGHTENED) {580 // var b = (this.pos[0] - halfBLOCKSIZE) / 8581 // c = (this.pos[1] - halfBLOCKSIZE) / 8582 // var tilePos = [Math.round(b) * 8 + halfBLOCKSIZE, Math.round(c) * 8 + halfBLOCKSIZE];583 var b = this.pos[0]-(this.pos[0]+(BLOCKSIZE<<2))%BLOCKSIZE;584 var c = this.pos[1]-(this.pos[1]+(BLOCKSIZE<<2))%BLOCKSIZE;585 var tilePos = [Math.round(b) + halfBLOCKSIZE, Math.round(c) + halfBLOCKSIZE];586 if (tilePos[0] != this.tilePos[0] || tilePos[1] != this.tilePos[1]) {//移动到了新的块587 this.tilePos[0] = tilePos[0];588 this.tilePos[1] = tilePos[1];589 this.mainRef.tilesChanged = true;590 }591 }592 }593 if (this.dir) {594 if (this.mode == ACTORMODE.EATEN) {595 this.animIdx = 47 + Dir2Anim[this.dir];596 } else {597 if (this.renderMode == ACTORMODE.FRIGHTENED) {//this.mainRef.frightModeTime) {598 //if ((this.mode == ACTORMODE.FRIGHTENED || ((this.mode == ACTORMODE.LEAVING_PEN || this.mode == ACTORMODE.IN_PEN)&& this.leavedPen==false)) && this.mainRef.frightModeTime) {//this.mainRef.frightModeTime) {599 this.animIdx = 32 + Math.floor(this.mainRef.frame / 3) % 2;600 if (this.mainRef.frightModeTime < this.mainRef.levels.frightTotalTime - this.mainRef.levels.frightTime)601 this.animIdx += Math.floor(this.mainRef.frame / 12) % 2 * 2;602 } else {603 if (this.id == this.mainRef.playerCount) {604 this.animIdx = 0 + Math.floor(this.mainRef.frame / 3) % 2 + Dir2Anim[this.dir] * 2;605 } else if (this.id == this.mainRef.playerCount + 1) {606 this.animIdx = 8 + Math.floor(this.mainRef.frame / 3) % 2 + Dir2Anim[this.dir] * 2;607 } else if (this.id == this.mainRef.playerCount + 2) {608 this.animIdx = 16 + Math.floor(this.mainRef.frame / 3) % 2 + Dir2Anim[this.dir] * 2;609 } else if (this.id == this.mainRef.playerCount + 3) {610 this.animIdx = 24 + Math.floor(this.mainRef.frame / 3) % 2 + Dir2Anim[this.dir] * 2;611 }612 }613 }614 }615 }616 updateSpeed() {//d617 this.speed = this.id == this.mainRef.playerCount && (this.mode == 2 || this.mode == 1) ? this.mainRef.cruiseElroySpeed : this.fullSpeed;618 }619 render(gameRes) {620 gameRes.renderImage(pacmanAnim[this.animIdx], this.pos[0], this.pos[1] + this.mainRef.worldMap.playfieldY, 1, 1);621 }...

Full Screen

Full Screen

constraints-fixed-block-size.js

Source:constraints-fixed-block-size.js Github

copy

Full Screen

1registerLayout('test', class {2 static get inputProperties() {3 return ['--expected-block-size'];4 }5 async intrinsicSizes() {}6 async layout([child], edges, constraints, styleMap) {7 let childFixedInlineSize = 0;8 let childFixedBlockSize = 0;9 if (constraints.fixedBlockSize === JSON.parse(styleMap.get('--expected-block-size'))) {10 childFixedInlineSize = 100;11 childFixedBlockSize = 100;12 }13 const childFragments = [await child.layoutNextFragment({14 fixedInlineSize: childFixedInlineSize,15 fixedBlockSize: childFixedBlockSize,16 })];17 return {childFragments};18 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2wptools.setConfig({fixedBlockSize: 100});3var wptools = require('wptools');4wptools.setConfig({fixedBlockSize: 200});5var wptools = require('wptools');6wptools.setConfig({fixedBlockSize: 100});7wptools.setConfig({fixedBlockSize: 200});8var wptools = require('wptools');9wptools.setConfig({fixedBlockSize: 100});10wptools.setConfig({fixedBlockSize: 200});11var wptools = require('wptools');12wptools.setConfig({fixedBlockSize: 100});13wptools.setConfig({fixedBlockSize: 200});14var wptools = require('wptools');15wptools.setConfig({fixedBlockSize: 100});16wptools.setConfig({fixedBlockSize: 200});17var wptools = require('wptools');18wptools.setConfig({fixedBlockSize: 100});19wptools.setConfig({fixedBlockSize: 200});20var wptools = require('wptools');21wptools.setConfig({fixedBlockSize: 100});22wptools.setConfig({fixedBlockSize: 200});23var wptools = require('wptools');24wptools.setConfig({fixedBlockSize: 100});25wptools.setConfig({fixedBlockSize: 200});26var wptools = require('wptools');27wptools.setConfig({fixedBlockSize: 100});28wptools.setConfig({fixedBlockSize: 200});29var wptools = require('wptools');30wptools.setConfig({fixedBlockSize: 100});31wptools.setConfig({fixedBlockSize: 200});32var wptools = require('wptools');33wptools.setConfig({fixedBlockSize: 100});34wptools.setConfig({fixedBlockSize: 200});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wp-tools');2var fs = require('fs');3var fixedBlockSize = wptools.fixedBlockSize;4var data = fs.readFileSync('test.txt');5var result = fixedBlockSize(data, 3);6console.log(result);7console.log(result.length);8var wptools = require('wp-tools');9var fixedBlockSize = wptools.fixedBlockSize;10var data = fs.readFileSync('test.txt');11var result = fixedBlockSize(data, 3);12console.log(result);13console.log(result.length);14var wptools = require('wp-tools');15var fixedBlockSize = wptools.fixedBlockSize;16var data = fs.readFileSync('test.txt');17var result = fixedBlockSize(data, 3);18console.log(result);19console.log(result.length);20var wptools = require('wp-tools');21var fixedBlockSize = wptools.fixedBlockSize;22var data = fs.readFileSync('test.txt');23var result = fixedBlockSize(data, 3);24console.log(result);25console.log(result.length);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var size = wptools.fixedBlockSize();3console.log(size);4var wptools = require('wptools');5var size = wptools.fixedBlockSize(2);6console.log(size);7var wptools = require('wptools');8var size = wptools.fixedBlockSize(3);9console.log(size);10var wptools = require('wptools');11var size = wptools.fixedBlockSize(4);12console.log(size);13var wptools = require('wptools');14var size = wptools.fixedBlockSize(5);15console.log(size);16var wptools = require('wptools');17var size = wptools.fixedBlockSize(6);18console.log(size);19var wptools = require('wptools');20var size = wptools.fixedBlockSize(7);21console.log(size);22var wptools = require('wptools');23var size = wptools.fixedBlockSize(8);24console.log(size);25var wptools = require('wptools');26var size = wptools.fixedBlockSize(9);

Full Screen

Using AI Code Generation

copy

Full Screen

1var fixedBlockSize = wpt.fixedBlockSize(1000);2var fixedBlockSize = wpt.fixedBlockSize(1000, 500);3var fixedBlockSize = wpt.fixedBlockSize(1000, 500, 250);4var fixedBlockSize = wpt.fixedBlockSize(1000, 500, 250, 100);5var fixedBlockSize = wpt.fixedBlockSize(1000, 500, 250, 100, 50);6var fixedBlockSize = wpt.fixedBlockSize(1000, 500, 250, 100, 50, 25);7var fixedBlockSize = wpt.fixedBlockSize(1000, 500, 250, 100, 50, 25, 10);8var fixedBlockSize = wpt.fixedBlockSize(1000, 500, 250, 100, 50, 25, 10, 5);9var fixedBlockSize = wpt.fixedBlockSize(1000, 500, 250, 100, 50, 25, 10, 5, 1);10var fixedBlockSize = wpt.fixedBlockSize(1000, 500, 250, 100, 50, 25, 10, 5, 1, 0);11var fixedBlockSize = wpt.fixedBlockSize(1000, 500, 250, 100, 50, 25, 10, 5, 1, 0, -5);12var fixedBlockSize = wpt.fixedBlockSize(1000, 500, 250, 100, 50, 25, 10, 5, 1, 0, -5, -10);13var fixedBlockSize = wpt.fixedBlockSize(1000, 500, 250, 100, 50, 25, 10, 5, 1, 0, -5, -10, -25);14var fixedBlockSize = wpt.fixedBlockSize(100

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var blockSize = 100;3var file = 'test.txt';4var fixedBlockSize = wptools.fixedBlockSize(blockSize, file);5fixedBlockSize(function(err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log(data);10 }11});12{ totalBlocks: 10, blockCount: 100 }13var wptools = require('wptools');14var blockSize = 100;15var file = 'test.txt';16wptools.fixedBlockSize(blockSize, file)17 .then(function(data) {18 console.log(data);19 })20 .catch(function(err) {21 console.log(err);22 });23{ totalBlocks: 10, blockCount: 100 }24var wptools = require('wptools');25var blockSize = 100;26var file = 'test.txt';27async function test() {28 try {29 var data = await wptools.fixedBlockSize(blockSize, file);30 console.log(data);31 } catch (err) {32 console.log(err);33 }34}35test();36{ totalBlocks: 10, blockCount: 100 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var block = wptools.fixedBlockSize(1000);3var offset = block.store('Hello World!');4var data = block.get(offset);5console.log(data);6console.log(block.size());7console.log(block.used());8console.log(block.free());9console.log(block.max());10console.log(block.used());11console.log(block.free());12console.log(block.max());13console.log(block.used());14console.log(block.free());15console.log(block.max());16console.log(block.used());17console.log(block.free());18console.log(block.max());19console.log(block.used());20console.log(block.free());21console.log(block.max());22console.log(block.used());

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful