@code-dot-org/maze
Advanced tools
Comparing version 2.4.0 to 2.10.0
{ | ||
"name": "@code-dot-org/maze", | ||
"version": "2.4.0", | ||
"version": "2.10.0", | ||
"description": "standalone project for the Maze app type", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
@@ -395,2 +395,22 @@ const {SVG_NS, pegmanElements} = require('./constants'); | ||
/** | ||
* Schedule the animations for a turn to the given direction, without | ||
* animating any of the intermediate frames. | ||
* @param {number} endDirection The direction we're turning to | ||
* @param {string} pegmanId Optional id of pegman. If no id is provided, | ||
* will schedule turn for default pegman. | ||
*/ | ||
simpleTurn(endDirection, pegmanId) { | ||
var numFrames = 2; | ||
utils.range(1, numFrames).forEach((frame) => { | ||
timeoutList.setTimeout(() => { | ||
this.displayPegman( | ||
this.maze.getPegmanX(pegmanId), | ||
this.maze.getPegmanY(pegmanId), | ||
tiles.directionToFrame(endDirection), | ||
pegmanId); | ||
}, this.maze.stepSpeed * (frame - 1)); | ||
}); | ||
} | ||
crackSurroundingIce(targetX, targetY) { | ||
@@ -397,0 +417,0 @@ // Remove cracked ice, replace surrounding ice with cracked ice. |
@@ -279,2 +279,13 @@ /** | ||
/** | ||
* A version of animated turn that bypasses the mod in animatedTurn | ||
* and moves straight to the direction given. | ||
* @param direction | ||
* @param id | ||
*/ | ||
animatedCardinalTurn(direction, id) { | ||
this.animationsController.simpleTurn(direction, id); | ||
this.setPegmanD(direction, id); | ||
} | ||
animatedFail(forward, id) { | ||
@@ -281,0 +292,0 @@ var dxDy = tiles.directionToDxDy(this.getPegmanD(id)); |
import Subtype from './subtype'; | ||
import NeighborhoodCell from './neighborhoodCell'; | ||
import NeighborhoodDrawer from './neighborhoodDrawer'; | ||
import { Direction } from './tiles'; | ||
@@ -92,4 +93,3 @@ module.exports = class Neighborhood extends Subtype { | ||
/** | ||
* Remove paint from the location of the pegman with id pegmanId, if there | ||
* is any paint. | ||
* Remove paint from the location of the pegman with id pegmanId. | ||
* @param {String} pegmanId | ||
@@ -101,4 +101,2 @@ **/ | ||
const cell = this.getCell(row, col); | ||
cell.setColor(null); | ||
this.drawer.resetTile(row, col); | ||
@@ -108,2 +106,25 @@ this.drawer.updateItemImage(row, col, true); | ||
/** | ||
* Turns the painter left by one direction. | ||
* @param {String} pegmanId | ||
*/ | ||
turnLeft(pegmanId) { | ||
let newDirection = null; | ||
switch (this.maze_.getPegmanD(pegmanId)) { | ||
case Direction.NORTH: | ||
newDirection = Direction.WEST; | ||
break; | ||
case Direction.EAST: | ||
newDirection = Direction.NORTH; | ||
break; | ||
case Direction.SOUTH: | ||
newDirection = Direction.EAST; | ||
break; | ||
case Direction.WEST: | ||
newDirection = Direction.SOUTH; | ||
break; | ||
} | ||
this.maze_.animatedCardinalTurn(newDirection, pegmanId); | ||
} | ||
takePaint(pegmanId) { | ||
@@ -118,2 +139,6 @@ const col = this.maze_.getPegmanX(pegmanId); | ||
reset() { | ||
this.drawer.resetTiles(); | ||
} | ||
// Sprite map maps asset ids to sprites within a spritesheet. | ||
@@ -120,0 +145,0 @@ getSpriteMap() { |
@@ -82,2 +82,9 @@ const { SVG_NS } = require("./drawer"); | ||
/** | ||
* Set the color of this tile back to null, and remove any svg elements | ||
* (colors) that currently exist on this tile and its neighbors. | ||
* | ||
* @param row | ||
* @param col | ||
*/ | ||
resetTile(row, col) { | ||
@@ -90,2 +97,4 @@ let neighbors = [ | ||
]; | ||
const cell = this.neighborhood.getCell(row, col); | ||
cell.setColor(null); | ||
for (const neighbor of neighbors) { | ||
@@ -127,3 +136,12 @@ var node = document.getElementById(neighbor); | ||
resetTiles() {} | ||
/** | ||
* Calls resetTile for each tile in the grid, clearing all paint. | ||
*/ | ||
resetTiles() { | ||
for (let row = 0; row < this.map_.ROWS; row++) { | ||
for (let col = 0; col < this.map_.COLS; col++) { | ||
this.resetTile(row, col); | ||
} | ||
} | ||
} | ||
@@ -130,0 +148,0 @@ // Quick helper to retrieve the color stored in this cell |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1449885
95
6987
1