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

switched to use fapi to point to ressources

parent 0e7fcf50
No related branches found
No related tags found
No related merge requests found
......@@ -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';
......
......@@ -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) {
......
......@@ -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,
......
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