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) { ...@@ -9,7 +9,7 @@ function Char(svg, options) {
this.loaded = false; this.loaded = false;
var self = this; 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'); self.image = self.svg.append('g').attr('id', 'player');
var layers = d3.select(xml.documentElement).selectAll('g').filter(function() { var layers = d3.select(xml.documentElement).selectAll('g').filter(function() {
return this.getAttribute('inkscape:groupmode') == 'layer'; return this.getAttribute('inkscape:groupmode') == 'layer';
......
...@@ -4,28 +4,17 @@ function Game(config) { ...@@ -4,28 +4,17 @@ 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('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 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");
...@@ -37,13 +26,11 @@ Game.prototype.run = function() { ...@@ -37,13 +26,11 @@ Game.prototype.run = function() {
// animate // animate
setInterval(function() { setInterval(function() {
if (char.loaded) { // move player
// move player char.physics();
char.physics(); char.animate();
char.animate(); // cam movement
// cam movement cam.movement();
cam.movement();
}
}, 10); }, 10);
svg.on("click", function(d) { svg.on("click", function(d) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<script src="jslib/d3.min.js" type="text/javascript"></script> <script src="jslib/d3.min.js" type="text/javascript"></script>
<script src="jslib/priority-queue.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="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/svgUtils.js" type="text/javascript"></script>
<script src="js/pathFinder.js" type="text/javascript"></script> <script src="js/pathFinder.js" type="text/javascript"></script>
<script src="js/vector.js" type="text/javascript"></script> <script src="js/vector.js" type="text/javascript"></script>
...@@ -21,6 +22,9 @@ ...@@ -21,6 +22,9 @@
<script> <script>
g_smallValue = 0.000001; // fun with floats g_smallValue = 0.000001; // fun with floats
var FAPI = new FAPI();
FAPI.methodBasepath = '';
var game = new Game({ var game = new Game({
startMap: 'map_landing.svg', startMap: 'map_landing.svg',
showEventLayers: false, 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