diff --git a/registration-system/view/signups/game1/MAP_HOWTO.md b/registration-system/view/signups/game1/MAP_HOWTO.md index fb752c9151591f4156ff8b323d8191f634bc6231..acc768925f40dc8f27d4f6d8fb331ee46f632a99 100644 --- a/registration-system/view/signups/game1/MAP_HOWTO.md +++ b/registration-system/view/signups/game1/MAP_HOWTO.md @@ -34,6 +34,8 @@ Folgende Attribute sollten gesetzt werden: - trigger (= walkon, hover, click) - type (= achievement, mapchange, ...) - stopsWalk (= true, false) +- target (optional, für map type für mapchange) +- destination (optional, target map für mapchange) - id Am Beispiel eines Achievements, welches beim drüberlaufen gefeuert wird und die Bernd weiterlaufen lässt: @@ -48,6 +50,6 @@ Am Beispiel eines Achievements, welches beim drüberlaufen gefeuert wird und die Dies aktiviert das Achievement "first_step" (wie definiert, siehe `js/achievements.js`) -Ganz wichtig in dieser Ebene: Ein Objekt mit der ID="player_spawn"! +Ganz wichtig in der Start-Ebene: Ein Objekt mit der ID="player_spawn", ansonsten target nutzen. Konvention: spawn roter Kreis, walkon pink, mapchange grün, ... ; Ebene leicht transparent \ No newline at end of file diff --git a/registration-system/view/signups/game1/js/character.js b/registration-system/view/signups/game1/js/character.js index c8ee14b43b68e470eb84be3a40795182c68e5abd..28fe7dcb8495b222abd2b201e4725db98a3b4bbb 100644 --- a/registration-system/view/signups/game1/js/character.js +++ b/registration-system/view/signups/game1/js/character.js @@ -3,7 +3,7 @@ function Char(svg, options) { this.svg = svg; this.pathFinder = new PathFinder(svg); - this.translation = options.spawn ? options.spawn : this.findSpawn(); + this.translation = options.spawn ? options.spawn : this.findSpawn(options ? options.spawnid : null); this.moveTarget = []; this.maxSpeed = 2; this.loaded = false; @@ -23,10 +23,10 @@ function Char(svg, options) { self.loaded = true; }); } -Char.prototype.findSpawn = function() { +Char.prototype.findSpawn = function(spawnId) { // [1320, svgFlipY(svg[0][0], 500)] - var spawn = this.svg.select("#player_spawn"); - if (!spawn[0][0]) console.error("Could not find spawn"); + var spawn = this.svg.select(spawnId ? '#'+spawnId : "#player_spawn"); + if (!spawn[0][0]) console.error("Could not find spawn: #" + spawnId); var bbox = spawn[0][0].getBBox(); return Vec.add(getTranslation(this.svg[0][0], spawn[0][0]), [bbox.x, bbox.y]); }; diff --git a/registration-system/view/signups/game1/js/events.js b/registration-system/view/signups/game1/js/events.js index a734408df01dc96b20b255ce9d9cda8de2d2fe48..b3143883d214e60084007ddf79f16e10dd495f1c 100644 --- a/registration-system/view/signups/game1/js/events.js +++ b/registration-system/view/signups/game1/js/events.js @@ -20,6 +20,8 @@ function EventHandler(svg) { id: this.getAttribute('id'), type: this.getAttribute('type'), trigger: trigger, + target: this.getAttribute('target'), + destination: this.getAttribute('destination'), stopsWalk: this.getAttribute('stopsWalk') === 'true' }); } @@ -60,8 +62,8 @@ EventHandler.prototype.handleEvent = function (event, context) { case 'achievement': Game.achievements.triggerAchievement(event.id, context); break; - case 'map': - Game.instance.nextMap(event.id); + case 'mapchange': + Game.instance.nextMap(event.destination, event.target); break; } diff --git a/registration-system/view/signups/game1/js/game.js b/registration-system/view/signups/game1/js/game.js index cab3cf2d2c28d946b7fc34a450d53b3ace902368..19aac7a5043ec5390c33b54de57044f2d6685f49 100644 --- a/registration-system/view/signups/game1/js/game.js +++ b/registration-system/view/signups/game1/js/game.js @@ -16,7 +16,7 @@ Game.prototype.run = function() { this.loadMap(Game.config.startMap); }; -Game.prototype.nextMap = function (map) { +Game.prototype.nextMap = function (map, spawn) { clearInterval(Game.mainLoop); Game.mainLoop = null; var gameRoot = document.getElementById("gameRoot"); @@ -25,17 +25,17 @@ Game.prototype.nextMap = function (map) { } Game.char = null; Game.cam = null; - this.loadMap(map); + this.loadMap(map, spawn); }; -Game.prototype.loadMap = function(map) { +Game.prototype.loadMap = function(map, spawn) { var gameCanvas = document.getElementById("gameCanvas"); var gameRoot = document.getElementById("gameRoot"); var svg = null; var initstack = [ - [initMap, map], + [initMap, map, spawn], [initMouse], [startMainLoop] ]; @@ -47,7 +47,8 @@ Game.prototype.loadMap = function(map) { init(); - function initMap(mapId, done) { + function initMap(mapId, spawn, done) { + console.log('Init map: ' + mapId + ' spawn: ' + spawn); d3.xml(FAPI.resolvePath('maps/'+mapId+'.svg'), 'image/svg+xml', function(xml) { gameCanvas.style.width = Game.config.size[0]+'px'; @@ -72,7 +73,7 @@ Game.prototype.loadMap = function(map) { // ------------------------------------- // init view stuff - Game.char = new Char(svg); + Game.char = new Char(svg, {spawnid: spawn}); Game.cam = new Camera(svg, Game.char.translation); diff --git a/registration-system/view/signups/game1/maps/castle_entrance.svg b/registration-system/view/signups/game1/maps/castle_entrance.svg index 44bbf7d30207b6b6409bf37c8dae780d5c96773e..d467263247b118c3f99790d2afece89fa1a0daf9 100644 Binary files a/registration-system/view/signups/game1/maps/castle_entrance.svg and b/registration-system/view/signups/game1/maps/castle_entrance.svg differ diff --git a/registration-system/view/signups/game1/maps/map_landing.svg b/registration-system/view/signups/game1/maps/map_landing.svg index 49a20ee79407637998996e97ce3a55cb890ae23a..396f3da5aa7e501f9e95309eaf646d19264fc4f7 100644 Binary files a/registration-system/view/signups/game1/maps/map_landing.svg and b/registration-system/view/signups/game1/maps/map_landing.svg differ