Location: PHPKode > projects > Dominant Creature RPG > class/class_world.php
<?php
require_once ("data_class.php");



class World extends Data {

var $wx = 100; // max world width
var $wy = 100; // max world height

var $qx = 10; // quadrant X
var $qy = 10; // quadrant Y

var $radius = 10; // maybe we'll need this


	function ShowMap() {
		
		if (isset($_POST["q"]) && isset($_POST["Change"]) && $_POST["Change"] == 'Change' && !preg_match("/[^0-9]+/", $_POST["q"]) && $_POST["q"] != '') 
		{
			$q = mysql_real_escape_string($_POST["q"]);
		} 
		
		else {
			$q = 1;
			 }
		
		$sq = mysql_query("SELECT * FROM strongholds WHERE quadrant = $q");
		
		$r = 1;
		while ($r <= mysql_num_rows($sq)) {
			
			$d[$r] = mysql_fetch_assoc($sq); // as $d = data of that row

			$this->s[$d[$r][xcoo]][$d[$r][ycoo]][pid] = $d[$r][player_creatures_id];
			$this->s[$d[$r][xcoo]][$d[$r][ycoo]][name] = $d[$r][name];
			
			
			$r++;
		}
		//start of table layout and quadrant selection
		echo "<table width='410' cellpading='0' celspacing='0' align='center' border='0' style='margin-top:20px;'>
		<tr><td colspan='10'>
		<form action='?p=world' method='POST'>
		Current Region: <input type='text' value='$q' style='width:30px' maxlength='2' name='q' /><input type='submit' value='Change' name='Change' />
		</form>
		</td></tr>
		<tr>";
		
		$i = 1;
		$xi = 1;
		$yi = 1;
		while ($i <= 100) {
			
			//echo $this->s[$xi][$yi][pid];
			
		if ($this->s[$xi][$yi][pid] == $_SESSION["id"]) {

		echo "<td width='36' height='36' align='center' bgcolor='#339933' title='".$this->s[$xi][$yi][name]."'><img src='img/castle.gif' border='0'/></td>";	
			
		}

		if ($this->s[$xi][$yi][pid] != $_SESSION["id"] && $this->s[$xi][$yi][pid] != '') {

		echo "<td width='36' height='36' align='center' bgcolor='#339933' title='".$this->s[$xi][$yi][name]."'><img src='img/castle2.gif' border='0'/></td>";	
			
		}

		else if ($this->s[$xi][$yi][pid] == ''){
			
		echo "<td width='36' height='36' align='center' bgcolor='#339933' title='[ x:$xi, y:$yi ]'><font color='#000000'></font></td>";
		}
		
		
		if ($i % 10 == 0) {echo "</tr><tr>"; $yi = $yi + 1; $xi = $xi - 10;}
		
		$i++;
		$xi++;
		}
		// end of table layout
		echo "</tr></table>";
		
	}
	
	
	
	
}
?>
Return current item: Dominant Creature RPG