From 01da57c5ae311f168d2a00f37d8fa2bd71a70b50 Mon Sep 17 00:00:00 2001 From: Tim Repke <timmothey@gmx.de> Date: Fri, 21 Aug 2015 14:10:30 +0200 Subject: [PATCH] switched to use fapi to point to ressources --- .../view/signups/game1/js/character.js | 2 +- .../view/signups/game1/js/game.js | 27 +++++-------------- .../view/signups/game1/test.html | 4 +++ 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/registration-system/view/signups/game1/js/character.js b/registration-system/view/signups/game1/js/character.js index 3c3768e..39eea83 100644 --- a/registration-system/view/signups/game1/js/character.js +++ b/registration-system/view/signups/game1/js/character.js @@ -9,7 +9,7 @@ function Char(svg, options) { this.loaded = false; var self = this; - d3.xml('chars/bernd.svg', 'image/svg+xml', function(xml) { + d3.xml(FAPI.resolvePath('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'; diff --git a/registration-system/view/signups/game1/js/game.js b/registration-system/view/signups/game1/js/game.js index 61a6e6e..74ca3e8 100644 --- a/registration-system/view/signups/game1/js/game.js +++ b/registration-system/view/signups/game1/js/game.js @@ -4,28 +4,17 @@ function Game(config) { Game.config = config; Game.instance = this; } -Game.eventLayers = ['CLICKABLE', 'WALK', 'NOWALK', 'EVENT']; Game.prototype.run = function() { - d3.xml('maps/'+Game.config.startMap, 'image/svg+xml', function(xml) { + d3.xml(FAPI.resolvePath('maps/map_landing.svg'), 'image/svg+xml', function(xml) { var gameCanvas = document.getElementById("gameCanvas"); var gameRoot = document.getElementById("gameRoot"); gameCanvas.style.width = Game.config.size[0]+'px'; gameCanvas.style.height = Game.config.size[1]+'px'; gameRoot.appendChild(xml.documentElement); - + var svg = d3.select("svg"); - - var displayEvents = Game.config.showEventLayers ? 'block' : 'none'; - svg.selectAll('g').filter(function() { - return ( - this.getAttribute('inkscape:groupmode') == 'layer' - && Game.eventLayers.indexOf(this.getAttribute('inkscape:label')) >= 0 - ); - }).style('display', displayEvents); - var char = new Char(svg); var cam = new Camera(svg, char.translation); - // test animation var ship = svg.select("#shipGroup"); @@ -37,13 +26,11 @@ Game.prototype.run = function() { // animate setInterval(function() { - if (char.loaded) { - // move player - char.physics(); - char.animate(); - // cam movement - cam.movement(); - } + // move player + char.physics(); + char.animate(); + // cam movement + cam.movement(); }, 10); svg.on("click", function(d) { diff --git a/registration-system/view/signups/game1/test.html b/registration-system/view/signups/game1/test.html index 28ff1bd..01b8752 100644 --- a/registration-system/view/signups/game1/test.html +++ b/registration-system/view/signups/game1/test.html @@ -5,6 +5,7 @@ <script src="jslib/d3.min.js" type="text/javascript"></script> <script src="jslib/priority-queue.min.js" type="text/javascript"></script> <script src="jslib/checkLineIntersection.js" type="text/javascript"></script> +<script src="../../js/api.js" type="text/javascript"></script> <script src="js/svgUtils.js" type="text/javascript"></script> <script src="js/pathFinder.js" type="text/javascript"></script> <script src="js/vector.js" type="text/javascript"></script> @@ -21,6 +22,9 @@ <script> g_smallValue = 0.000001; // fun with floats +var FAPI = new FAPI(); +FAPI.methodBasepath = ''; + var game = new Game({ startMap: 'map_landing.svg', showEventLayers: false, -- GitLab