Graal Forums  

Go Back   Graal Forums > Development Forums > Graphic Design
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #20  
Old 11-19-2011, 02:46 PM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
yes, its pretty old. Also as semantic I see no problem use "i". its pretty webstandart since its from first html.

You can replace the render function for this one
PHP Code:
    <?Php 

class graalLevel{
    var 
$tile = array();
    var 
$imgFolder 'images/';
    var 
$defaultTileset 'pics1.png';
    function 
prepare(){
        
file_exists($this->imgFolder) or mkdir($this->imgFolder);
        
file_exists($this->imgFolder.$this->defaultTileset) or die("Please, first save {$this->defaultTileset} file in folder '{$this->imgFolder}'.");
    }
    function 
graalLevel($lvl){
        
$this->prepare();
        
preg_match_all('/board \d \d+ \d\d \d (.*)/ei',$lvl,$r);
        function 
convertLine($a,$b,&$o){
            foreach(
str_split($a2) as $c=>$d)$o->tile[$b][$c] = $o->tileSetCoordinates($d);
        }    
        
array_walk($r[1],'convertLine',$this);
    }
    function 
tileSetCoordinates($d){
        
$seq 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
        
$_ strpos($seq,$d[1])+strpos($seq,$d[0])*64;
        return array(
floor((floor($_/512)*16+($_%16))*16),floor((floor($_/16)%32)*16));
    }
    function 
render(){
        
$img imagecreatetruecolor(1024,1024);
        
$tileSet imagecreatefrompng($this->imgFolder.$this->defaultTileset);
        for(
$i=0;$i<64;$i++)for($j=0;$j<64;$j++)            
        
imagecopy($img,$tileSet,$j*16,$i*16,(count($this->tile)>0?$this->tile[$i][$j][0]:'0'),(count($this->tile)>0?$this->tile[$i][$j][1]:),16,16);
        
header("Content-type: image/jpeg");
        
imagejpeg($img,NULL,100);
    }
}
if(
array_key_exists('arq',$_FILES) && $_FILES['arq']['size']>&& is_array($t pathinfo($_FILES['arq']['name'])) && $t['extension'] == 'nw'){
    
$level = new graalLevel(    file_get_contents($_FILES['arq']['tmp_name'])    );
    
$level->render();
}
?>
<form method="post" enctype="multipart/form-data">Select nw file:<input type="file" name="arq" /><input type="submit" name="submit" value="enviar"/></form>
than you get the result as image and pretty fast.

Last edited by amonrabr; 11-19-2011 at 02:57 PM..
Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:55 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.