Skip to content
Snippets Groups Projects
Commit 25928d1b authored by Tim Repke's avatar Tim Repke
Browse files

revert last commit; editor had an old version of the file in cache

parent 01da57c5
No related branches found
No related tags found
No related merge requests found
...@@ -4,18 +4,29 @@ function Game(config) { ...@@ -4,18 +4,29 @@ function Game(config) {
Game.config = config; Game.config = config;
Game.instance = this; Game.instance = this;
} }
Game.eventLayers = ['CLICKABLE', 'WALK', 'NOWALK', 'EVENT'];
Game.prototype.run = function() { Game.prototype.run = function() {
d3.xml(FAPI.resolvePath('maps/map_landing.svg'), 'image/svg+xml', function(xml) { d3.xml(FAPI.resolvePath('maps/'+Game.config.startMap), 'image/svg+xml', function(xml) {
var gameCanvas = document.getElementById("gameCanvas"); var gameCanvas = document.getElementById("gameCanvas");
var gameRoot = document.getElementById("gameRoot"); var gameRoot = document.getElementById("gameRoot");
gameCanvas.style.width = Game.config.size[0]+'px'; gameCanvas.style.width = Game.config.size[0]+'px';
gameCanvas.style.height = Game.config.size[1]+'px'; gameCanvas.style.height = Game.config.size[1]+'px';
gameRoot.appendChild(xml.documentElement); gameRoot.appendChild(xml.documentElement);
var svg = d3.select("svg"); 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 char = new Char(svg);
var cam = new Camera(svg, char.translation); var cam = new Camera(svg, char.translation);
// test animation // test animation
var ship = svg.select("#shipGroup"); var ship = svg.select("#shipGroup");
ship ship
...@@ -23,19 +34,20 @@ Game.prototype.run = function() { ...@@ -23,19 +34,20 @@ Game.prototype.run = function() {
ship.transition() ship.transition()
.duration(3000) .duration(3000)
.attr("transform", function(d,i) { return "translate(0,0)"; }); .attr("transform", function(d,i) { return "translate(0,0)"; });
// animate // animate
setInterval(function() { setInterval(function() {
// move player if (char.loaded) {
char.physics(); // move player
char.animate(); char.physics();
// cam movement char.animate();
cam.movement(); // cam movement
cam.movement();
}
}, 10); }, 10);
svg.on("click", function(d) { svg.on("click", function(d) {
char.setMoveTarget(d3.event.pageX, d3.event.pageY); char.setMoveTarget(d3.event.pageX, d3.event.pageY);
}); });
}); });
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment