diff --git a/.gitignore b/.gitignore index 1e3a9006cd7af835ea2e24b88bc1fed9e5364193..2a02d23039529acacd429616ad8067b29dbf0b4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.idea/* */.idea* */view/signups/game1/tiles +*.swp diff --git a/registration-system/view/signups/game1/chars/bernd.svg b/registration-system/view/signups/game1/chars/bernd.svg new file mode 100644 index 0000000000000000000000000000000000000000..27ddaae090dbcfbae14a7f5f7da8ea00d5cca43f Binary files /dev/null and b/registration-system/view/signups/game1/chars/bernd.svg differ diff --git a/registration-system/view/signups/game1/js/character.js b/registration-system/view/signups/game1/js/character.js index 93a22971cdc4f8a3dad5062f9e14286286222f0f..fca0afb94d8c570e6c4674cb11136fa5f4f54b2a 100644 --- a/registration-system/view/signups/game1/js/character.js +++ b/registration-system/view/signups/game1/js/character.js @@ -7,12 +7,17 @@ function Char(svg, options) { this.moveTarget = []; this.maxSpeed = 2; - this.rect = this.svg.append("rect"); - this.rect.attr("backgroundColor", "#f0f") - .attr("width", "20") - .attr("height", "20"); - - this.updatePosition(); + var self = this; + d3.xml('chars/bernd.svg', 'image/svg+xml', function(xml) { + self.image = self.svg.append('g').attr('id', 'player'); + var layers = d3.select(xml.documentElement).selectAll('g').filter(function() { + return this.getAttribute('inkscape:groupmode') == 'layer'; + }).each(function() { + self.image[0][0].appendChild(this); + }); + + self.updatePosition(); + }); } Char.prototype.findSpawn = function() { // [1320, svgFlipY(svg[0][0], 500)] @@ -47,14 +52,13 @@ Char.prototype.physics = function() { this.updatePosition(); } Char.prototype.updatePosition = function() { + if (!this.image) return; var self = this; - this.rect.attr("transform", function() { + this.image.attr("transform", function() { return translate.apply(null, self.translation); }); } Char.prototype.setMoveTarget = function(newX, newY) { - if (!this.rect) return; - var matrix = this.svg[0][0].getScreenCTM(); var x = newX-matrix.e; var y = newY-matrix.f;