diff --git a/registration-system/view/signups/game1/js/character.js b/registration-system/view/signups/game1/js/character.js index 66ec1339ed11afee9e2d06794c32f7934e2425c0..93a22971cdc4f8a3dad5062f9e14286286222f0f 100644 --- a/registration-system/view/signups/game1/js/character.js +++ b/registration-system/view/signups/game1/js/character.js @@ -17,8 +17,8 @@ function Char(svg, options) { Char.prototype.findSpawn = function() { // [1320, svgFlipY(svg[0][0], 500)] var spawn = this.svg.select("#player_spawn"); - var b = spawn[0][0].getBBox(); - return [b.x, b.y]; + var bbox = spawn[0][0].getBBox(); + return Vec.add(getTranslation(this.svg[0][0], spawn[0][0]), [bbox.x, bbox.y]); } Char.prototype.animate = function() { } diff --git a/registration-system/view/signups/game1/js/pathFinder.js b/registration-system/view/signups/game1/js/pathFinder.js index d0594a485969750909cda1cfa657662ccf7963d2..476b31b0579d4bb0a7262b669eb3de01e074dd16 100644 --- a/registration-system/view/signups/game1/js/pathFinder.js +++ b/registration-system/view/signups/game1/js/pathFinder.js @@ -18,11 +18,13 @@ PathFinder.prototype.scanWalkables = function() { if (!self.noWalkNode && label == "NOWALK") self.noWalkNode = this; }); + var walkTranslation = getTranslation(this.svg[0][0], this.walkNode); d3.select(self.walkNode).selectAll('path').each(function() { - self.walkNodes.push(new Path(this.getAttribute("d"))); + self.walkNodes.push(new Path(this.getAttribute("d"), walkTranslation)); }); + var noWalkTranslation = getTranslation(this.svg[0][0], this.noWalkNode); d3.select(self.noWalkNode).selectAll('path').each(function() { - self.noWalkNodes.push(new Path(this.getAttribute("d"))); + self.noWalkNodes.push(new Path(this.getAttribute("d"), noWalkTranslation)); }); } PathFinder.prototype.generateRaster = function() { diff --git a/registration-system/view/signups/game1/js/svgUtils.js b/registration-system/view/signups/game1/js/svgUtils.js index 875dec8913627d2f6bed5a8156bc216bb3434986..3714798e1dd708bc39e867e252561e912f29d01e 100644 --- a/registration-system/view/signups/game1/js/svgUtils.js +++ b/registration-system/view/signups/game1/js/svgUtils.js @@ -7,12 +7,17 @@ function showCoords(x, y) { function svgFlipY(svg, y) { return svg.getBBox().height - y; } +function getTranslation(svg, node) { + var matrix = svg.getTransformToElement(node); + return [matrix.e, matrix.f]; +} -function Path(svgPathData) { +function Path(svgPathData, offset) { this.edges = []; var currentPosition = [0,0]; + if (!offset) offset = [0,0]; var relativeCommand = true; var currentCommand = 'm'; @@ -32,7 +37,7 @@ function Path(svgPathData) { if (isNumber) { currentPosition = part.split(","); for (var i = 0; i < currentPosition.length; ++i) - currentPosition[i] = (relativeCommand ? lastPosition[i] : 0) + Number(currentPosition[i]); + currentPosition[i] = offset[i]+(relativeCommand ? lastPosition[i] : 0) + Number(currentPosition[i]); if (currentCommand == 'l') this.edges.push([lastPosition, currentPosition]);