Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@code-dot-org/maze

Package Overview
Dependencies
Maintainers
13
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@code-dot-org/maze - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

2

package.json
{
"name": "@code-dot-org/maze",
"version": "2.1.0",
"version": "2.2.0",
"description": "standalone project for the Maze app type",

@@ -5,0 +5,0 @@ "main": "dist/main.js",

@@ -5,2 +5,3 @@ const {SVG_NS, pegmanElements} = require('./constants');

const getPegmanYForRow = drawMap.getPegmanYForRow;
const addNewPegman = drawMap.addNewPegman;
const timeoutList = require('./timeoutList');

@@ -131,4 +132,6 @@ const utils = require('./utils');

} else {
// TODO: reset for mazes with placeholder/multiple pegmen
if (!this.maze.subtype.initializeWithPlaceholderPegman() && !this.maze.subtype.allowMultiplePegmen()) {
// Reset the pegman for a maze with 1 pegman. Mazes that allow multiple
// pegmen will only show/hide a static default, which is
// reset by the maze controller.
if (!this.maze.subtype.allowMultiplePegmen()) {
this.displayPegman(this.maze.getPegmanX(), this.maze.getPegmanY(), tiles.directionToFrame(this.maze.getPegmanD()));

@@ -157,5 +160,7 @@ }

// Reset pegman's visibility.
var pegmanIcon = this.getPegmanIcon();
pegmanIcon.setAttribute('opacity', 1);
// Reset pegman's visibility if there is only one pegman
const pegmanIcon = this.getPegmanIcon();
if (!this.maze.subtype.allowMultiplePegmen()) {
pegmanIcon.setAttribute('opacity', 1);
}

@@ -168,3 +173,3 @@ if (this.maze.skin.idlePegmanAnimation) {

idlePegmanIcon.setAttribute('visibility', 'visible');
} else {
} else if (!this.maze.subtype.allowMultiplePegmen()) {
pegmanIcon.setAttribute('visibility', 'visible');

@@ -583,2 +588,12 @@ }

hidePegman(pegmanId) {
var pegmanIcon = this.getPegmanIcon(pegmanId);
pegmanIcon.setAttribute('visibility', 'hidden');
}
showPegman(pegmanId) {
var pegmanIcon = this.getPegmanIcon(pegmanId);
pegmanIcon.setAttribute('visibility', 'visible');
}
/**

@@ -709,2 +724,6 @@ * Schedule the animations and sound for a dance.

}
addNewPegman(pegmanId, x, y, d) {
addNewPegman(this.maze.skin, pegmanId, x, y, d, this.svg);
}
};

@@ -47,3 +47,5 @@ const {SVG_NS, pegmanElements} = require('./constants');

pegmanIcon.setAttribute('height', skin.pegmanHeight);
pegmanIcon.setAttribute('width', skin.pegmanWidth * 21); // 49 * 21 = 1029
// default pegman sheet has 21 sprites. Skin may override with a specific width for the sheet.
const sheetWidth = skin.pegmanSheetWidth || skin.pegmanWidth * 21
pegmanIcon.setAttribute('width', sheetWidth);
pegmanIcon.setAttribute('clip-path', `url(#${pegmanClipId})`);

@@ -157,1 +159,2 @@ svg.appendChild(pegmanIcon);

module.exports.displayPegman = displayPegman;
module.exports.addNewPegman = addNewPegman;

@@ -168,4 +168,6 @@ /**

* @param {boolean} first True if an opening animation is to be played.
* @param {boolean} showDefault True if the default pegman should be shown. Only applies
* to subtypes that allow multiple pegman
*/
reset(first) {
reset(first, showDefault = true) {
this.subtype.reset();

@@ -175,10 +177,20 @@

timeoutList.clearTimeouts();
// Move Pegman into position.
if (!this.subtype.initializeWithPlaceholderPegman()) {
if (this.subtype.start) {
// Move default Pegman into position.
this.setPegmanX(this.subtype.start.x);
this.setPegmanY(this.subtype.start.y);
this.setPegmanD(this.startDirection);
} else {
// TODO: remove all pegmen except the default
}
if (this.subtype.allowMultiplePegmen()) {
// hide all pegman except the default. Show the default if it exists and
// showDefault is true
const pegmanIds = this.pegmanController.getAllPegmanIds();
pegmanIds.forEach(pegmanId => {
this.pegmanController.isDefaultPegman(pegmanId) && showDefault
? this.animationsController.showPegman(pegmanId)
: this.animationsController.hidePegman(pegmanId);
});
}
this.animationsController.reset(first);

@@ -400,5 +412,37 @@

addPegman(id, x, y, d) {
// if pegman with id <id> already exists, reset
// its location and direction. Otherwise, create a
// new pegman and add it to the maze.
if (this.pegmanController.getPegman(id)) {
this.animationsController.hidePegman(id);
const pegman = this.pegmanController.getPegman(id);
pegman.setX(x);
pegman.setY(y);
pegman.setDirection(d);
var frame = tiles.directionToFrame(d);
this.animationsController.displayPegman(
x,
y,
frame,
id
);
this.animationsController.showPegman(id);
} else {
this.createAndDisplayPegman(id, x, y, d);
}
}
createAndDisplayPegman(id, x, y, d) {
const pegman = new Pegman(id, x, y, d);
this.pegmanController.addPegman(pegman);
this.animationsController.addNewPegman(id, x, y, d);
}
hideDefaultPegman() {
// if default pegman exists, hide it
if (this.pegmanController.getPegman()) {
this.animationsController.hidePegman();
}
}
};

@@ -11,4 +11,3 @@ import Subtype from './subtype';

// TODO: these should be defined by the level
this.initializeWithPlaceholder = true;
// TODO: this should be defined by the level
this.squareSize = 50;

@@ -31,9 +30,2 @@ }

/**
* @override
*/
initializeWithPlaceholderPegman() {
return this.initializeWithPlaceholder;
}
/**

@@ -40,0 +32,0 @@ * @override

const Drawer = require('./drawer')
const tiles = require('./tiles');

@@ -16,3 +17,5 @@ module.exports = class NeighborhoodDrawer extends Drawer {

const cell = this.neighborhood.getCell(row, col);
if (cell.getAssetId() != null) {
// If the tile has an asset id, return the sprite asset. Ignore the asset id
// if this is a start tile, as start tiles will handle placing the pegman separately.
if (cell.getAssetId() != null && cell.getTile() !== tiles.SquareType.START) {
return this.neighborhood.getSpriteMap()[cell.getAssetId()];

@@ -19,0 +22,0 @@ }

@@ -37,2 +37,10 @@ const Pegman = require('./pegman');

}
getAllPegmanIds() {
return Object.keys(this.pegmen);
}
isDefaultPegman(pegmanId) {
return pegmanId == undefined || pegmanId === DEFAULT_PEGMAN_ID;
}
}

@@ -247,7 +247,2 @@ const Cell = require('./cell');

}
// Whether this subtype should be initialized with a placeholder pegman. Default false.
initializeWithPlaceholderPegman() {
return false;
}
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc