diff options
author | BlueRaja <BlueRaja.admin@gmail.com> | 2012-08-18 19:50:47 -0500 |
---|---|---|
committer | BlueRaja <BlueRaja.admin@gmail.com> | 2012-08-18 19:50:47 -0500 |
commit | d2b27af54e560591e44393de0d22fd8621c3320c (patch) | |
tree | 2d8809d4594e0a3b548451e34ab15fdd6ebbf059 /includes/maps.php | |
parent | 55656d931a05f533e11b8a3860c5dce4c66c88ca (diff) | |
parent | 4f00fc760a2d01542d70a5f3cbafea360b3766d6 (diff) | |
download | pathery-d2b27af54e560591e44393de0d22fd8621c3320c.tar.xz |
Merge branch 'master' of git.raylu.net:pathery
Diffstat (limited to 'includes/maps.php')
-rw-r--r-- | includes/maps.php | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/includes/maps.php b/includes/maps.php index 7a2996d..b168b35 100644 --- a/includes/maps.php +++ b/includes/maps.php @@ -35,6 +35,9 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL) {
case 's': $maptable .= "<td title='Start tile. Position: $j,$i' class='grid_td_start' id='$handle' >
<div id='child_$handle' class='grid_inner'></div></td>"; break;
+
+ case 'S': $maptable .= "<td title='Start tile. Position: $j,$i' class='grid_td_startB' id='$handle' >
+ <div id='child_$handle' class='grid_inner'></div></td>"; break;
case 'f': $maptable .= "<td title='Finish tile. Position: $j,$i' class='grid_td_finish' id='$handle' >
<div id='child_$handle' class='grid_inner'></div></td>"; break;
//TP1
@@ -821,6 +824,7 @@ function findPath($mapMatrix, $start = '0,1', $target = 'f') { //!!
case "p":
case "s": case "f": //Start and end tiles
+ case "S": //!!
case "a": case "b": case "c": case "d": case "e": //Checkpoints too
case "u": case "n": case "h": case "j": case "l": //Teleport-out towers included!
@@ -876,13 +880,29 @@ function routePath($mygrid, $start = '', $validate = false) { //Our response
$r = array('start' => NULL, 'path' => NULL, 'blocked' => true);
- //Locate the start locations.
- $start = findTiles($mygrid, "s");
+
+ //Scan the map for these tiles.
+ // Doing this scan once is far more effecient than rescanning.
+ $tileLocations = findTilesM($mygrid, str_split('S'));
+
+ if (in_array($tileLocations, "S") {
+
+ }
+
+
+ // Tmp bad code..
+ if ($start == 'X')
+ $start = findTiles($mygrid, "S");
+ else
+ $start = findTiles($mygrid, "s");
+
+
//Checkpoint names
$cpnames = array("a", "b", "c", "d", "e");
+ //!! Improve the 'findTiles' function to prevent duplicate itterations.
//Add the existing checkpoints to target array.
foreach ($cpnames as $cpt)
if (findTiles($mygrid, $cpt))
@@ -1033,5 +1053,16 @@ function weight() { return $weights[rand(0, (count($weights) -1))];
}
+function findTilesM ($mapMatrix, $search) {
+ $r = array();
+ for( $i = 1; $i <= $mapMatrix[0][1]; $i++) { //Number of Rows
+ for( $j = 0; $j < $mapMatrix[0][0]; $j++) { //Number of Columns
+ foreach($search as $item)
+ if ($mapMatrix[$i][$j] == $item)
+ $r[$item][] = "$j,$i";
+ }
+ }
+ return $r;
+}
-?>
+?> |