Commit fd688bf4 authored by Orbmancer's avatar Orbmancer
Browse files

debugged level extraction

parent 95993ffa
......@@ -14,34 +14,46 @@ class Contents
$this->mapwidth = 5;
$this->mapheight = 5;
$this->contents = array(
array(array(), array(), array(), array(), array()),
array(array(), array(), array(), array(), array()),
array(array(), array(), array(), array(), array()),
array(array(), array(), array(), array(), array()),
array(array(), array(), array(), array(), array())); // coucou :)
$this->contents = array();
for($i=1; $i<=5; ++$i)
for($j=1; $j<=5; ++$j)
$this->contents[$i][$j] = array();
}
public function importXML($string) {
$xml = simplexml_load_string($string);
$this->contentsRaw = $xml->Data->contents->__toString();
echo 'RAW<br/>';
var_dump($this->contentsRaw);
echo '<br/>/GENERATE<br/>';
$contents = explode(',', $this->contentsRaw);
$line = array();
$prev_y = 1;
for($i=0; $i<count($contents); ++$i){
$tab_x = (int) floor($i / self::$tabwidth);
$tab_y = (int) floor($i / (self::$tabwidth * self::$tabheight * $this->mapwidth));
$tab_x = $this->getTabX($i);
$tab_y = $this->getTabY($i);
$line[] = $contents[$i];
if($prev_y != $tab_y){
$this->contents[$tab_x][$tab_y] = $line;
/*echo '<br/>LINE '.count($this->contents[$tab_x][$tab_y]).'<br/>';
var_dump($line);
echo '<br/>';*/
$this->contents[$tab_x][$tab_y][] = $line;
$line = array();
}
}
}
private function getTabX($index){
return (int) floor($index / self::$tabwidth) % 5 +1;
}
private function getTabY($index){
return (int) floor($index / (self::$tabwidth * $this->mapwidth * self::$tabheight)) +1;
}
public function setContents($contents) {
$this->contents = $contents;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment