summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2012-12-12 19:28:47 -0800
committerPatrick Davison <snapwilliam@gmail.com>2012-12-12 19:28:47 -0800
commitbb073d3992e25cea8276550f7644979dd3bdfba4 (patch)
tree843c5b9596da5cfeb7cf571264e7551c0effe0fd /js
parent7a087e906f120f61cbe51f98b0e76079b0f9c13f (diff)
downloadpathery-bb073d3992e25cea8276550f7644979dd3bdfba4.tar.xz
mapspecs.js fixes and cleanups
Diffstat (limited to 'js')
-rw-r--r--js/mapspecs.js100
1 files changed, 48 insertions, 52 deletions
diff --git a/js/mapspecs.js b/js/mapspecs.js
index cf3de15..43e6c56 100644
--- a/js/mapspecs.js
+++ b/js/mapspecs.js
@@ -129,7 +129,7 @@ function grid_click(obj) {
else
obj.style.backgroundColor = playerWallColor;
- if (typeof playerWallEmblem !== 'undefined')
+ if (typeof playerWallEmblem !== 'undefined' && playerWallEmblem !== '')
obj.style.backgroundImage="url(images/marks/"+playerWallEmblem+")";
//Add Wall
@@ -303,17 +303,17 @@ function decryptJSON(text) {
function animatePath(path, mapid, start, pathNumber) {
- tmp = start.split(',');
- y = tmp[0];
- x = tmp[1];
+ var tmp = start.split(',');
+ var y = tmp[0];
+ var x = tmp[1];
- p = path;
- //t = p.length;
- t = '';
- //count[mapid] = 0;
+ var p = path;
+ //Prepare the path
+ var c = p.substring(0, 1);
+ p = p.substring(1);
+
document.getElementById(mapid+',btn').disabled = true;
- doanimate(x, y, p, t, mapid, pathNumber);
- //setTimeout("doanimate("+x+","+y+",'"+p+"',"+t+")",500);
+ doanimate(x, y, p, c, mapid, pathNumber);
}
function animatePathDone(mapid) {
@@ -335,7 +335,6 @@ function checkSound(mapid) {
return true;
}
-//var snake = new Array();
function doanimate(x, y, p, c, mapid, pathNumber) {
//x, y position
@@ -348,24 +347,15 @@ function doanimate(x, y, p, c, mapid, pathNumber) {
if (count[mapid] == undefined) {
count[mapid] = 0;
}
- //TODO: Delete
- // if (snake[mapid] == undefined) {
- // snake[mapid] = new Array();
- // mapdata[mapid].pathColor[pathNumber] = '#ccc';
- // }
- if (count[mapid] == 0) {
- if (t == 'a') {
- mapdata[mapid].pathColor[pathNumber] = '#F777FF';
- }
- if (t == 'f') {
- mapdata[mapid].pathColor[pathNumber] = '#ccc';
- }
- }
+ //Set the color for the first target.
+ if (count[mapid] == 0 && !(c > 0))
+ mapdata[mapid].pathColor[pathNumber] = targetColor(c);
//Display movecount
- if (mapdata[mapid].moveCount[1] > 0) {
+
+ if (mapdata[mapid].moveCount[1] > 0 && mapdata[mapid].moveCount[0] > 0)
updateDsp(mapid, 'dspCount', mapdata[mapid].moveCount[0] + ' + ' + mapdata[mapid].moveCount[1] + ' = ' + count[mapid] + " moves");
- } else
+ else
updateDsp(mapid, 'dspCount', count[mapid]+ " moves");
//document.getElementById(mapid+',dspCount').innerHTML = count[mapid]+ " moves";
@@ -402,6 +392,7 @@ function doanimate(x, y, p, c, mapid, pathNumber) {
c = '2';
}
+
switch(c) {
//The path is moving to a new position
case '1': //1 - Up
@@ -629,30 +620,11 @@ function doanimate(x, y, p, c, mapid, pathNumber) {
//Special codes within the path.
//Did we aquire a target?
//Checkpoint targets:
- case 'a':
- rs = rs + 410;
- mapdata[mapid].pathColor[pathNumber] = '#F777FF';
- break;
- case 'b':
- rs = rs + 410;
- mapdata[mapid].pathColor[pathNumber] = '#FFFF11';
- break;
- case 'c':
- rs = rs + 410;
- mapdata[mapid].pathColor[pathNumber] = '#FF4466';
- break;
- case 'd':
- rs = rs + 410;
- mapdata[mapid].pathColor[pathNumber] = '#ff9911';
- break;
- case 'e':
+
+ case 'a': case 'b': case 'c':
+ case 'd': case 'e': case 'f':
rs = rs + 410;
- mapdata[mapid].pathColor[pathNumber] = '#00FFFF';
- break;
- //Finish target
- case 'f':
- rs = rs + 410;
- mapdata[mapid].pathColor[pathNumber] = '#ccc';
+ mapdata[mapid].pathColor[pathNumber] = targetColor(t);
break;
//Hey, we've ran into a teleport.
@@ -678,9 +650,6 @@ function doanimate(x, y, p, c, mapid, pathNumber) {
soundManager.setPan('ufoblip', -70);
soundManager.play('ufoblip');
}
-
- //document.getElementById(eid).style.backgroundColor='#CCCCCC';
- //document.getElementById(tpEid).style.backgroundColor='#CCCCCC';
document.getElementById(tpEid).style.backgroundColor='';
flashelement(tpEid, 8, mapdata[mapid].pathColor[pathNumber]);
@@ -701,6 +670,33 @@ function doanimate(x, y, p, c, mapid, pathNumber) {
setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"','"+pathNumber+"')",rs);
}
+
+function targetColor(target) {
+ var r = '#ccc';
+ switch(target) {
+ case 'a':
+ r = '#F777FF';
+ break;
+ case 'b':
+ r = '#FFFF11';
+ break;
+ case 'c':
+ r = '#FF4466';
+ break;
+ case 'd':
+ r = '#ff9911';
+ break;
+ case 'e':
+ r = '#00FFFF';
+ break;
+ case 'f':
+ r = '#ccc';
+ }
+ return r;
+}
+
+
+
function flashelement(eid, times, color, speed) {
if (document.getElementById(eid) == undefined) return;
if (!color) {