• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# map printing, map to screen

## Recommended Posts

killercow    122
i have a couple of tricky questions for you guys. lets say i have a 50x50 map, i print this normally, (in html, so i use a table) the map works fine. now lets make a diamond shaped map from this. we rotate the map 45 degrees zo that i stand on one of its corners. now lets say, 0-0 sits on top and 50-50 is on the bottom. i use a browser so i won''t need to handle scrolling, i just need the coordinates on which to print the layers containing the image , this coordinate will be in the top left corner on each layer. i also have to handle even and uneven rows. i allready contacted my math teacher and a couple of other people, but my script just doesn''t work. does anyone know any good algorithems to deal with this? i can''t post my sollution which is not working anyway coz im at work right now.

##### Share on other sites
killercow    122
dudes? please i am really fed up with this problem, maybe im just pain stupid but i just don't see it.

anyway here my code for now.

its php but that wouldn't matter right?

$width=30; // width of each image$height=30;	// height of each image$isometricheight=$height/2;	// the difference that couses isometry to apear in height$isometricwidth=$width/2;	// the difference that couses isometry to apear in width$rows=50;$cols=50;function getlocation($coords){ global$width, $height,$isometricheight,$isometricwidth,$rows,$cols;$centerline=$rows/2;$subarray=explode("-", $coords); // make sure we explode the coords into to seperate peices x and y // get the y coordinates by calculations. settype($subarray[0], "integer");	settype($subarray[1], "integer"); echo"$subarray[0]  $subarray[1]"; if ($subarray[0] % 2 == 1) {		$y=((($subarray[0]/2)*$height)+$isometricheight);		// this interger is uneven	} else {		$y=($subarray[0]/2)*$height; } // get the x coordinates by calculations. if ($subarray[1] % 2 == 1) {		$x=((($subarray[1]/2+$centerline)*$width)+$isometricwidth); // this interger is uneven } else {$x=(($subarray[1]/2)+$centerline)*$width; } echo"<div id=\""; echo$coords;	echo"\" nonostyle=\"position:absolute; left=";	echo $x; echo"px; top="; echo$y;	echo"px\">$coords</div>";}// dbase connecten// and get 2500 cells, with these thingy's (50-2) etcfunction dbconnect() { mysql_pconnect("localhost", "*****", "*****" ); mysql_select_db("******") or die ("Unable to select database");}dbconnect();$result=mysql_query("select * from webgame");while(list($id,$bgr, $inh,$p1, $p2,$p3, $p4,$game, $owner)=mysql_fetch_array($result)){	getlocation(\$id);}?>

moo?

Edited by - killercow on February 2, 2002 4:28:15 PM