Welcome to the Browser-Base Game Zone forums!
<?php$number_of_tiles_x = 15;$number_of_tiles_y = 15;$tile_width = 50;$tile_height = 50;$map_height = $tile_height*$number_of_tiles_y;$map_width = $tile_width*$number_of_tiles_x;?><html><head><style type="text/css">#map { width: <?php echo $map_width; ?>px; height: <?php echo $map_height; ?>px; background-color: #000; position:relative;}.tile { width: <?php echo $tile_width+$number_of_tiles_x+12; ?>px; height: <?php echo $tile_height+$number_of_tiles_y+12; ?>px; position:absolute;}</style></head><body><?phpecho "<center><h1>Test Map</h1><br />$number_of_tiles_x | $number_of_tiles_y<br /> is number of tiles on XAxis | is number of tiles on YAxis</center><br />";?><div id="map"><?phpfor ($x = 1;$x<$number_of_tiles_x;$x++){ for ($y = 1;$y<$number_of_tiles_y;$y++){ $tx = $x * $tile_height / 2 * 1.5; $ty = $y * $tile_height + ($x % 2) * $tile_height / 2; $style = sprintf("left:%dpx;top:%dpx", $tx, $ty); echo "<img src=\"plain.gif\" class=\"tile\" style=\"$style\" />\n"; }}?></div></body></html>
<?phpob_start();session_start();$action = $_GET['act'];$actions_array = array('forgot_password','about','TandC');?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="text/css" href="styles/main.css" /> <?php $site = "medieval-wars.com"; $title = "Home"; ?> <title> <?php echo "$site - $title"; ?> </title> <style type="text/css">.page-top-sceen-island { background-image: url(../images/bg-island.png); top:150px; width:300px; height:164px; right:-1098px; position:relative;}.page-top-sceen-island-for-IE { display:none;}</style><!--[if IE]><style type="text/css">.page-top-sceen-island-for-IE { display: block; background-image: url(../images/bg-island.png); top:150px; width:300px; height:164px; right:-1096px; position:relative; }.page-top-sceen-island { display: none; }</style><![endif]--> </head> <body> <div id="page-top"> <div id="page-top-top"> <div id="page-top-under"> </div> </div> <div id="page-top-sceen-logo"> <div style="font-size:16pt;color: #000;"><br /><br /> <a title="medieval-wars.com" href="http://medieval-world.webuda.com/">We are at war!<br />Now it is your time to lead our nation to victory!<br />medieval-wars.com </a> </div> </div> <div id="page-top-sceen-left"> </div> <div id="page-top-sceen-island-wrapper"><div class="page-top-sceen-island"></div><div class="page-top-sceen-island-for-IE"></div></div> </div> <div id="main-content-character" title="King"> </div> <div id="left-side-bar"> <ul class="ul-box"> <li class="li-top"> <div style="position:relative;top:6px;"> <h1 title="Register for free">Register for free</h1> </div><br /> </li> <li class="content"><?phpif (isset($_POST['register'])) { $regusername = $_POST['username']; $regemail = $_POST['email']; $regserver = $_POST['server'];}else { $regusername = ''; $regemail = ''; $regserver = 0;}$servers = array(0=>'Select Your World...', 1=>'S1 Medieval-Europe', );$regform = " <form action=\"testing.php\" method=\"post\"> <div class=\"input-wrap\"> <label title=\"Username\">Username</label><br /> <input type=\"text\" name=\"username\" value=\"$regusername\" title=\"Username\" style=\"\" /> </div> <div class=\"input-wrap\"> <label title=\"Password\">Password</label><br /> <input type=\"password\" name=\"password\" value=\"\" title=\"Password\" style=\"\" /> </div> <div class=\"input-wrap\"> <label title=\"Confirm Password\">Confirm Password</label><br /> <input type=\"password\" name=\"confpassword\" value=\"\" title=\"Confirm Password\" style=\"\" /> </div> <div class=\"input-wrap\"> <label title=\"Email\">Email</label><br /> <input type=\"text\" name=\"email\" value=\"$regemail\" title=\"Email\" style=\"\" /> </div> <div class=\"input-wrap\"> <label title=\"Choose Your World\">World</label><br /> <select name=\"server\" title=\"Select Your World...\">"; foreach ($servers as $snum=>$sname) { if ($regserver == $snum) $selectedserver = 'selected="selected"'; else $selectedserver = ''; $regform .= " <option value=\"$snum\" title=\"$sname\" $selectedserver >$sname</option> "; }$regform .= " </select> </div> <div style=\"padding-left:60px;\"> <input type=\"submit\" name=\"register\" value=\"Register\" title=\"Register\" class=\"button\" /> </div> </form>";if($_POST['register']){ $regpassword = $_POST['password']; $regconfpassword = $_POST['confpassword']; //$regform2 = "<form action=\"index.php\" method=\"post\"><div class=\"input-wrap\"><label title=\"Username\">Username</label><br /><input type=\"text\" name=\"username\" value=\"$regusername\" title=\"Username\" style=\"\" /></div><div class=\"input-wrap\"><label title=\"Password\">Password</label><br /><input type=\"password\" name=\"password\" value=\"\" title=\"Password\" style=\"\" /></div><div class=\"input-wrap\"><label title=\"Confirm Password\">Confirm Password</label><br /><input type=\"password\" name=\"confpassword\" value=\"\" title=\"Confirm Password\" style=\"\" /></div><div class=\"input-wrap\" title=\"Email\"><label>Email</label><br /><input type=\"text\" name=\"email\" value=\"$regemail\" title=\"Email\" style=\"\" /></div><div class=\"input-wrap\"><label title=\"Choose Your World\">World</label><br /><select name=\"server\" title=\"Select Your World...\"><option value=\"0\" title=\"Select Your World...\">Select Your World...</option><option value=\"1\" title=\"S1 Medieval-Europe\">S1 Medieval-Europe</option></select></div><div style=\"padding-left:60px;\"><input type=\"submit\" name=\"register\" value=\"Register\" title=\"Register\" class=\"button\" /></div></form>"; $regform2 = $regform; if($regusername && $regpassword && $regconfpassword && $regemail && $regserver){ if($regpassword === $regconfpassword){ if(strlen($regusername) >= 3 && strlen($regusername) <= 32){ if(strlen($regpassword) >= 8 && strlen($regpassword) <= 32){ include "./scripts/connect.php"; $regsql = "SELECT username FROM `users` WHERE `username`='".$regusername."'"; $regres = mysql_query($regsql) or die(mysql_error()); if(mysql_num_rows($regres) > 0){ echo "$regform<font style=\"padding-left:20px;\">That username is already in use!</font><br /><br />"; }else { $regsql2 = "SELECT email FROM `users` WHERE `email`='".$regemail."'"; $regres2 = mysql_query($regsql2) or die(mysql_error()); if(mysql_num_rows($regres2) > 0){ echo "$regform<font style=\"padding-left:20px;\">That email is already in use!</font><br /><br />"; }else { $checkemail = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i"; if(preg_match($checkemail, $regemail)){ $regCorX = mt_rand(1,400); $regCorY = mt_rand(1,400); $regallCorssql = "SELECT * FROM cities WHERE CorX='".$regCorX."' AND CorY='".$regCorY."'"; $regallCorsres = mysql_query($regallCorssql) or die(mysql_error()); if(mysql_num_rows($regallCorsres) > 0){ echo "$regform<font style=\"padding-left:20px;\">There was an error <br /><b>(Error Code \"1\")</b></font><br /><br />"; }else { $regIP_adress = $_SERVER['REMOTE_ADDR']; $regrand_act_code = substr(md5(rand(1111111111, 99999999999999)), 2, 25); $regrand_login_code = substr(md5(rand(1212121212, 88888888888888)), 5, 50); $regencrypted_regpassword = md5(md5("kjfiufj".$regpassword."Fdj56fj")); $regsql3 = "INSERT INTO users VALUES ('', '$regusername', '$regencrypted_regpassword', '$regemail', '0', '$regIP_adress', '0', '$regusername', '$regserver', '', '', '$regrand_act_code', '$regrand_login_code', '1', '1')"; $regres3 = mysql_query($regsql3) or die(mysql_error()); $regsql4 = "INSERT INTO profile VALUES ('', '$regserver', '$regusername', '0', '0', 'This user hasn&#039;t entered any profile text yet.', 'default.png', '1', 'Polis')"; $regres4 = mysql_query($regsql4) or die(mysql_error()); $regsql5 = "INSERT INTO cities VALUES ('', '$regserver', 'Polis', '$regusername', '$regCorX', '$regCorY', '1')"; $regres5 = mysql_query($regsql5) or die(mysql_error()); } }else { echo "$regform<font style=\"padding-left:20px;\">That is an invalid email!</font><br /><br />"; } } } }else { echo "$regform<font style=\"padding-left:10px;\">Your password has to be atleast 8 to <br /><font style=\"padding-left:10px;\">32 characters in length!</font></font><br /><br />"; } }else { echo "$regform<font style=\"padding-left:10px;\">Your username has to be atleast 3 to <br /><font style=\"padding-left:10px;\">32 characters in length!</font></font><br /><br />"; } }else { echo "$regform<font style=\"padding-left:20px;\">Those passwords do not match!</font><br /><br />"; } }else { echo "$regform<font style=\"padding-left:20px;\">You must fill in the entire form!</font><br /><br />"; }}else { echo $regform;} ?> </li> <li class="li-bottom"> </li> </ul> </div> <div id="content"> <div id="box"> <div id="top"> </div> <div id="bottom"> </div> <div style="text-align:center;"><?php if(!$action || !in_array($action,$actions_array)){ echo "<p style=\"text-decoration:underline\">Home Page</p>"; }else { if($action == 'TandC'){ include "./T&C.php"; } } ?> </div> </div> </div> </body></html><?phpob_end_flush();?>
-- phpMyAdmin SQL Dump-- version 2.11.4-- http://www.phpmyadmin.net---- Host: localhost-- Generation Time: Jul 28, 2011 at 12:49 AM-- Server version: 5.1.57-- PHP Version: 5.2.17SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";---- Database: `a8510207_game`---- ------------------------------------------------------------ Table structure for table `bann chance 2`--CREATE TABLE `#mysql50#bann chance 2` ( `id` int(11) NOT NULL AUTO_INCREMENT, `IP_address` varchar(50) COLLATE latin1_general_ci NOT NULL, `chance_2` int(11) NOT NULL DEFAULT '1', `date` varchar(50) COLLATE latin1_general_ci NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ;---- Dumping data for table `bann chance 2`---- ------------------------------------------------------------ Table structure for table `cities`--CREATE TABLE `cities` ( `id` int(11) NOT NULL AUTO_INCREMENT, `server` varchar(10) COLLATE latin1_general_ci NOT NULL, `name` varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT 'Polis', `owner` varchar(50) COLLATE latin1_general_ci NOT NULL, `CorX` varchar(100) COLLATE latin1_general_ci NOT NULL, `CorY` varchar(100) COLLATE latin1_general_ci NOT NULL, `points` bigint(20) NOT NULL DEFAULT '1', PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=23 ;---- Dumping data for table `cities`--INSERT INTO `cities` VALUES(17, '1', 'Polis', 'testing3', '258', '11', 1);INSERT INTO `cities` VALUES(16, '1', 'Polis', 'testing4', '222', '367', 1);INSERT INTO `cities` VALUES(18, '1', 'Polis', 'testing2', '41', '198', 1);INSERT INTO `cities` VALUES(19, '1', 'Polis', 'Concept', '235', '258', 1);INSERT INTO `cities` VALUES(20, '1', 'Polis', 'a'' OR 1=1;', '400', '269', 1);INSERT INTO `cities` VALUES(21, '1', 'Polis', 'test', '89', '273', 1);INSERT INTO `cities` VALUES(22, '1', 'Polis', ''' OR 1=1 #', '382', '389', 1);-- ------------------------------------------------------------ Table structure for table `profile`--CREATE TABLE `profile` ( `id` int(11) NOT NULL AUTO_INCREMENT, `server` varchar(10) COLLATE latin1_general_ci NOT NULL, `username` varchar(50) COLLATE latin1_general_ci NOT NULL, `banned` int(11) NOT NULL DEFAULT '0', `activated` int(11) NOT NULL DEFAULT '0', `profile_text` text COLLATE latin1_general_ci NOT NULL, `profile_pic` varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT 'default.png', `points` bigint(20) NOT NULL DEFAULT '1', `cities` varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT 'Polis', PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=22 ;---- Dumping data for table `profile`--INSERT INTO `profile` VALUES(15, '1', 'testing4', 0, 0, 'This user hasn't entered any profile text yet.', 'default.png', 1, 'Polis');INSERT INTO `profile` VALUES(16, '1', 'testing3', 0, 0, 'This user hasn't entered any profile text yet.', 'default.png', 1, 'Polis');INSERT INTO `profile` VALUES(17, '1', 'testing2', 0, 0, 'This user hasn't entered any profile text yet.', 'default.png', 1, 'Polis');INSERT INTO `profile` VALUES(18, '1', 'Concept', 0, 0, 'This user hasn't entered any profile text yet.', 'default.png', 1, 'Polis');INSERT INTO `profile` VALUES(19, '1', 'a'' OR 1=1;', 0, 0, 'This user hasn't entered any profile text yet.', 'default.png', 1, 'Polis');INSERT INTO `profile` VALUES(20, '1', 'test', 0, 0, 'This user hasn't entered any profile text yet.', 'default.png', 1, 'Polis');INSERT INTO `profile` VALUES(21, '1', ''' OR 1=1 #', 0, 0, 'This user hasn't entered any profile text yet.', 'default.png', 1, 'Polis');-- ------------------------------------------------------------ Table structure for table `users`--CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) COLLATE latin1_general_ci NOT NULL, `password` varchar(200) COLLATE latin1_general_ci NOT NULL, `email` varchar(50) COLLATE latin1_general_ci NOT NULL, `activation` int(11) NOT NULL DEFAULT '0', `IP_address` varchar(20) COLLATE latin1_general_ci NOT NULL, `banned` int(11) NOT NULL DEFAULT '0', `profile` varchar(50) COLLATE latin1_general_ci NOT NULL, `server` varchar(20) COLLATE latin1_general_ci NOT NULL, `last_login` varchar(50) COLLATE latin1_general_ci NOT NULL, `last_logout` varchar(50) COLLATE latin1_general_ci NOT NULL, `rand_act_code` varchar(50) COLLATE latin1_general_ci NOT NULL, `rand_login_code` varchar(50) COLLATE latin1_general_ci NOT NULL, `cities` varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT '1', `points` bigint(20) NOT NULL DEFAULT '1', PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=22 ;---- Dumping data for table `users`--INSERT INTO `users` VALUES(16, 'testing3', '55983d8b233836b1d259055b38a985ab', 'testing3@testing3.com', 0, '71.177.16.172', 0, 'testing3', '1', '', '', '9030d4543159d697104966b2a', '80fe7030dabcefae89d29e8d002', '1', 1);INSERT INTO `users` VALUES(15, 'testing4', 'a23172c19886e344886727db01137e23', 'testing4@testing4.com', 0, '71.177.16.172', 0, 'testing4', '1', '', '', '09eec9b03706943dfa84a2b61', '9d5224bef3f3251b596e0c778f8', '1', 1);INSERT INTO `users` VALUES(17, 'testing2', '55983d8b233836b1d259055b38a985ab', 'testing2@testing2.com', 0, '173.55.248.113', 0, 'testing2', '1', '', '', 'cdc76ddde9479bc3f10ff9a0f', 'fb8b8c474995a1109c46fa8663a', '1', 1);INSERT INTO `users` VALUES(20, 'test', '55983d8b233836b1d259055b38a985ab', 'test@test.com', 0, '173.55.248.113', 0, 'test', '1', '', '', '625b0f5e7ecbeabc82c64beb6', '3de415652f9127b31ebbc07aad3', '1', 1);
$tile_width = 50;$tile_height = 50;
and my database looks like
this is pure mathsolution is to have DIV with absolute position <div style="position:absolute;left:XXXpx;top:YYYpx;"><img></div>http://www.w3schools.com/cssref/pr_class_position.aspread about that on pages and try it and of course you will need clickable links..you make that with MAP, and AREA:rectanglehttp://www.w3schools.com/tags/tag_map.aspP.S. make one big DIV and "write" that image DIVs inside it so absolute position will be used for that div and not for html page
Why both W and H use "$tile_height"? Where is $tile_width?Quote$tile_width = 50;$tile_height = 50;It is not square, it is isometric... Height has to be 1/2 of width. I know, it will mess up with the "buildings", still, in iso you need to make all calcuations based on the tile base, not on the maximum height of the gfx. The simpliest render would be probably "left:%dpx;BOTTOM:%dpx;".
i some what fixed the odd 8 by 16 problem by multiplying $number_of_tiles_x*2 and putting the < in the for loops to <= but i still get an error there is an extra row for both X and Y and for some odd reason they are randomly missing 1 tile each and i googled the diamond rendering method all i got where a bunch of art tutorials explaining how to paint a daimond a tutorial explaining how to make a daimond kite and a few tutorials explaining how to make daimonds but i only checked the first 6 pages of results most of this is my code the only part that is not is the positioning part because i suck at math and could not figure it out so i found a tutorial and used their positioning codeQuote from: saljutin on July 28, 2011, 10:17:18 AMthis is pure mathsolution is to have DIV with absolute position <div style="position:absolute;left:XXXpx;top:YYYpx;"><img></div>http://www.w3schools.com/cssref/pr_class_position.aspread about that on pages and try it and of course you will need clickable links..you make that with MAP, and AREA:rectanglehttp://www.w3schools.com/tags/tag_map.aspP.S. make one big DIV and "write" that image DIVs inside it so absolute position will be used for that div and not for html page thanks the map part will come in useful already know about the stuff in first link and i tried your suggestion and it kind of messed it upi tried to google a tutorial of how to make an isometric map in php could ony find one and of course no one replied to the users questioncan you guys please give me some sample code of how to make it into isometric?and about my database how could i make it betterand about the server thing i use shared hosting so i can't pick what computer gets used and i can have only 1 accountand my thoughts for the server thing waswith the existing test website i have my hosting service lets me do the sub link thingso for the server i could do S1-Medieval-Middle-East.medieval-world.webuda.comwhat would be bad about doing multible servers that way and also im not planning to have more then 1 server till the first gets over 1000 players which i dubt will happenQuote from: Chris on July 28, 2011, 05:03:26 AMWhy both W and H use "$tile_height"? Where is $tile_width?Quote$tile_width = 50;$tile_height = 50;It is not square, it is isometric... Height has to be 1/2 of width. I know, it will mess up with the "buildings", still, in iso you need to make all calcuations based on the tile base, not on the maximum height of the gfx. The simpliest render would be probably "left:%dpx;BOTTOM:%dpx;".so i divide tile height by 2 and change top: to bottom: ?
<?php$number_of_tiles_x = 14;$number_of_tiles_y = 14;$tile_width = 50.0;$tile_height = 50.0;$map_height = $tile_height*$number_of_tiles_y;$map_width = $tile_width*$number_of_tiles_x;?><html><head><style type="text/css">.tile { width: <?php echo $tile_width+28; ?>px; height: <?php echo $tile_height+32; ?>px; position:absolute;}#map {}</style></head><body><div id="map"><?phpfunction screen_position($m,$n){ GLOBAL $tile_height,$map_height; $tx = $m * $tile_height / 2 * 1.50 ; $ty = ($n +1)* $tile_height/2.0; return $gridpoint=array('x'=>$tx,'y'=>$ty);}for ($m=0;$m<$number_of_tiles_x;$m++){ for ($n=0;$n<$number_of_tiles_y;$n++) { $gridpoint = screen_position($m+$n,$number_of_tiles_y-$m+$n); $style = sprintf("left:%dpx;top:%dpx", $gridpoint['x'], $gridpoint['y']); echo "<img src=\"plain.gif\" class=\"tile\" style=\"$style\" />\n"; }}?></div></body></html>
<style> div.tile{ position:absolute; background: url(plain.gif) no-repeat -0px -20px; width: 70px; height:35px; }</style><?php$tileWidth = 70;$tileHeight = 35;$mapWidth = 5; //set the amount of tiles $mapHeight = 5;$xOffset = ($tileWidth * $mapWidth) / 2; //center the first tile$yOffset = 20; //put the map a bit lowerfor($y = 1;$y <= $mapHeight;$y++){ for($x = 1;$x <= $mapWidth;$x++){ $map .= '<div class="tile" style="top:'.round($yOffset).'px;left:'.round($xOffset).'px;"></div>'; $yOffset += $tileHeight/2; $xOffset += $tileWidth/2; } $xOffset = ($tileWidth * $mapWidth) / 2-$tileWidth/2*$y; //the new line starts again from center - half tilewidth * linenumber $yOffset = 20 + $tileHeight/2*$y;}echo $map;?>
<html><head><style> div.tile{ position:absolute; background: url(plain.gif) no-repeat -0px -20px; width: 70px; height:35px; text-align: center; curser: pointer: } img { border: none; } .map_click_point { position:absolute; text-align:center; height:35px; width:70px; padding-top:6px; }</style></head><body><?php$tileWidth = 70;$tileHeight = 34;$mapWidth = 14; //set the amount of tiles $mapHeight = 14;$xOffset = ($tileWidth * $mapWidth) / 2; //center the first tile$yOffset = 20; //put the map a bit lower$number = 0;for($y = 1;$y <= $mapHeight;$y++){ for($x = 1;$x <= $mapWidth;$x++){ $number ++; //positions the first layer $map .= "<div class=\"tile\" style=\"top:".round($yOffset)."px;left:".round($xOffset)."px;\">"; //for showing the images based on corridinates from the database on the seconed layer if($y=="1" && $x=="1" || $number=="19" || $number =="196"){ $map .= "<img src=\"test_image2.gif\" style=\"position:relative;top:-20;\" />"; }else { if($number=="15" || $y=="3" && $x=="5" || $y=="2" && $x=="2"){ $map .= "<img src=\"test-pc.gif\" style=\"position:relative;top:-9;\" />"; }else {} } //the third layer has the links $map .= "</div>\n<div class=\"map_click_point\" style=\"top:".round($yOffset)."px;left:".round($xOffset)."px;\"><a href=\"#spot=Xcord$y&Ycord$x\" id=\"$number\" title=\"$y | $x\"><img src=\"click.png\" style=\"width:27px;height:21px;\"/></a></div>\n\n"; $yOffset += $tileHeight/2; $xOffset += $tileWidth/2; } $xOffset = ($tileWidth * $mapWidth) / 2-$tileWidth/2*$y; //the new line starts again from center - half tilewidth * linenumber $yOffset = 20 + $tileHeight/2*$y;}echo "\n$map";?></body></html>
<style> .tile{ position:absolute; background: url(sprites.png) no-repeat; width:70px; height:55px; line-height: 70px; text-align: center; font-size: 12px; } .tile.plain{ background-position: 0px 0px; } .tile.town1{ background-position: -81px 0px; } .tile.town2{ background-position: -162px -2px; }</style><?php$myX = (isset($_GET['x']) ? $_GET['x'] : 0);$myY = (isset($_GET['y']) ? $_GET['y'] : 0);$tileWidth = 70;$tileHeight = 34;$mapWidth = 15;$mapHeight = 15;$startX = $myX - $mapWidth/2 ;$endX = $myX + $mapWidth/2;$startY = $myY- $mapHeight/2 ;$endY = $myY + $mapHeight/2;$xOffset = ($tileWidth * $mapWidth) / 2; //center the first tile$yOffset = 20; //put the map a bit lower$avaliableTiles = array( 'town1','town2','plain');$lineNumber = 1;for ($y = ceil($startY); $y < ceil($endY); $y++) { for ($x = ceil($startX); $x < ceil($endX); $x++) { $color= 'white'; if($myX == $x && $myY == $y){ $color='green'; } $map .= '<div class="tile '.$avaliableTiles[rand(0,count($avaliableTiles)-1)].'" style="color:'.$color.';top:' . round($yOffset) . 'px;left:' . round($xOffset) . 'px;">Y'.$y.'/X'.$x.'</div>'; $yOffset += $tileHeight / 2; $xOffset += $tileWidth / 2; } $xOffset = ($tileWidth * $mapWidth) / 2 - $tileWidth / 2 * $lineNumber; //the new line starts again from center - half tilewidth * linenumber $yOffset = 20 + $tileHeight / 2 * $lineNumber; $lineNumber++;}$step = (isset($_GET['step']) ? $_GET['step'] : 1);$directions = array( 'w'=>array('x'=>$myX,'y'=>$myY+$step), 's'=>array('x'=>$myX+$step,'y'=>$myY), 'e'=>array('x'=>$myX,'y'=>$myY-$step), 'n'=>array('x'=>$myX-$step,'y'=>$myY),);?><a href="<?= sprintf('?y=%s&x=%s&step=%s',$directions['w']['y'],$directions['w']['x'],$step)?>">West</a><a href="<?= sprintf('?y=%s&x=%s&step=%s',$directions['s']['y'],$directions['s']['x'],$step)?>">South</a><a href="<?= sprintf('?y=%s&x=%s&step=%s',$directions['n']['y'],$directions['n']['x'],$step)?>">North</a><a href="<?= sprintf('?y=%s&x=%s&step=%s',$directions['e']['y'],$directions['e']['x'],$step)?>">East</a><?= $map ?>
<html><head><style> div.tile{ position:absolute; background: url(plain.gif) no-repeat -0px -20px; width: 70px; height:35px; text-align: center; curser: pointer: } img { border: none; } .map_click_point { position:absolute; text-align:center; height:35px; width:70px; padding-top:6px; }</style></head><body><?php$myX = (isset($_GET['x']) ? $_GET['x'] : 8);$myY = (isset($_GET['y']) ? $_GET['y'] : 8);//for setting the corner viewsif($myX == "1" && $myY == "1"){ $myX = 8; $myY = 8;}if($myX == "1" && $myY == "400"){ $myX = 8; $myY = 394;}if($myX == "400" && $myY == "1"){ $myX = 394; $myY = 8;}if($myX == "400" && $myY == "400"){ $myX = 394; $myY = 394;}$tileWidth = 70;$tileHeight = 34;$mapWidth = 14; //set the amount of tiles $mapHeight = 14;$startX = $myX - $mapWidth/2 ;$endX = $myX + $mapWidth/2;$startY = $myY- $mapHeight/2 ;$endY = $myY + $mapHeight/2;$xOffset = ($tileWidth * $mapWidth) / 2; //center the first tile$yOffset = 20; //put the map a bit lower$lineNumber = 1;for ($y = ceil($startY); $y < ceil($endY); $y++) { for ($x = ceil($startX); $x < ceil($endX); $x++) { $color= 'white'; if($myX == $x && $myY == $y){ $color='green'; } //positions the first layer @$map .= "<div class=\"tile\" style=\"top:".round($yOffset)."px;left:".round($xOffset)."px;\">"; //for showing the images based on corridinates from the database on the seconed layer if($y=="1" && $x=="1" || $y=="2" && $x=="5" || $y =="14" && $x=="14"){ $map .= "<img src=\"test_image2.gif\" style=\"position:relative;top:-20;\" />"; }else { if($y=="2" && $x=="1" || $y=="3" && $x=="5" || $y=="2" && $x=="2"){ $map .= "<img src=\"test-pc.gif\" style=\"position:relative;top:-9;\" />"; }else {} } //the third layer has the links $map .= "</div>\n<div class=\"map_click_point\" style=\"color:".$color.";top:".round($yOffset)."px;left:".round($xOffset)."px;\"><a href=\"#spot=Xcord$y&Ycord$x\" title=\"$y | $x\"><img src=\"click.png\" style=\"width:27px;height:21px;\"/></a></div>\n\n"; $yOffset += $tileHeight/2; $xOffset += $tileWidth/2; } $xOffset = ($tileWidth * $mapWidth) / 2 - $tileWidth / 2 * $lineNumber; //the new line starts again from center - half tilewidth * linenumber $yOffset = 20 + $tileHeight / 2 * $lineNumber; $lineNumber++;}$step = 3;$directions = array( 'w'=>array('x'=>$myX-$step,'y'=>$myY), 's'=>array('x'=>$myX,'y'=>$myY+$step), 'e'=>array('x'=>$myX+$step,'y'=>$myY), 'n'=>array('x'=>$myX,'y'=>$myY-$step),);echo "\n$map";?><a href="<?php echo sprintf('?x=%s&y=%s',$directions['n']['x'],$directions['n']['y']); ?>">North</a><a href="<?php echo sprintf('?x=%s&y=%s',$directions['s']['x'],$directions['s']['y']); ?>">South</a><a href="<?php echo sprintf('?x=%s&y=%s',$directions['e']['x'],$directions['e']['y']); ?>">East</a><a href="<?php echo sprintf('?x=%s&y=%s',$directions['w']['x'],$directions['w']['y']); ?>">West</a><br /><?php echo "X".$myY." | Y".$myX.""; ?></body></html>
<style> .tile{ position:absolute; background: url(sprites.png) no-repeat; width:70px; height:55px; line-height: 70px; text-align: center; font-size: 12px; } .tile.plain{ background-position: 0px 0px; } .tile.town1{ background-position: -81px 0px; } .tile.town2{ background-position: -162px -2px; }</style><?php$startPosition = array(//getting player position from Database 'x' => 100, 'y' => 100);$myX = (isset($_GET['x']) ? $_GET['x'] : $startPosition['x']);$myY = (isset($_GET['y']) ? $_GET['y'] : $startPosition['y']);$mapLimit = array(//Setting up limits 'minX' => 1, 'maxX' => 400, 'minY' => 1, 'maxY' => 400);$mapArray = array(); //array with the map$viewX = 0; //X and Y which will be displayed on map$viewY = 0;$tileWidth = 70;$tileHeight = 34;$mapWidth = 15;$mapHeight = 15;$startX = $myX - $mapWidth / 2;$endX = $myX + $mapWidth / 2;$startY = $myY - $mapHeight / 2;$endY = $myY + $mapHeight / 2;$xOffset = ($tileWidth * $mapWidth) / 2; //center the first tile$yOffset = 20; //put the map a bit lower$avaliableTiles = array( 'town1', 'town2', 'plain');$lineNumber = 1;for ($y = ceil($startY); $y < ceil($endY); $y++) { for ($x = ceil($startX); $x < ceil($endX); $x++) { $viewX = $x; //View X and ViewY are the true X and Y Coordinates $viewY = $y; if ($x < $mapLimit['minX']) { $viewX = $mapLimit['maxX'] + $x; } if ($x > $mapLimit['maxX']) { $viewX = $mapLimit['minX'] - $x; } if ($y < $mapLimit['minY']) { $viewY = $mapLimit['maxY'] + $y; } if ($y > $mapLimit['maxY']) { $viewY = $mapLimit['minY'] - $y; } $map .= '<div class="tile ' . $avaliableTiles[2] . '" style="color:' . $color . ';top:' . round($yOffset) . 'px;left:' . round($xOffset) . 'px;">Y' . $viewY. '/X' . $viewX . '</div>'; $yOffset += $tileHeight / 2; $xOffset += $tileWidth / 2; } $xOffset = ($tileWidth * $mapWidth) / 2 - $tileWidth / 2 * $lineNumber; //the new line starts again from center - half tilewidth * linenumber $yOffset = 20 + $tileHeight / 2 * $lineNumber; $lineNumber++;}$step = (isset($_GET['step']) ? $_GET['step'] : 1);$directions = array( 'w' => array('x' => $myX, 'y' => $myY + $step), 's' => array('x' => $myX + $step, 'y' => $myY), 'e' => array('x' => $myX, 'y' => $myY - $step), 'n' => array('x' => $myX - $step, 'y' => $myY),);?><a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['w']['y'], $directions['w']['x'], $step) ?>">West</a><a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['s']['y'], $directions['s']['x'], $step) ?>">South</a><a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['n']['y'], $directions['n']['x'], $step) ?>">North</a><a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['e']['y'], $directions['e']['x'], $step) ?>">East</a><?= $map ?>
foreach($y..foreach($xmysql_query("SELECT tilename FROM towns WHERE x= "$viewX"And y="$viewY"
Quote from: BlackScorp on August 18, 2011, 04:04:53 AMforeach($y..foreach($xmysql_query("SELECT tilename FROM towns WHERE x= "$viewX"And y="$viewY"It's raping the database... You CAN'T, simply can't put a query in such loop It's immoral mysql_query("SELECT tilename,x,y FROM towns WHERE x<=$startx AND x>=$endx AND y<=$starty AND y>=$endy ORDER BY x,y");And then you have 1 query (not dozens or hundred) and use the loop to display it.
<style> .tile{ position:absolute; background: url(sprites.png) no-repeat; width:70px; height:55px; line-height: 70px; text-align: center; font-size: 12px; } .tile.plain{ background-position: 0px 0px; } .tile.town1{ background-position: -81px 0px; } .tile.town2{ background-position: -162px -2px; }</style><?php$startPosition = array(//getting player position from Database 'x' => 100, 'y' => 100);$myX = (isset($_GET['x']) ? $_GET['x'] : $startPosition['x']);$myY = (isset($_GET['y']) ? $_GET['y'] : $startPosition['y']);$mapLimit = array(//Setting up limits 'minX' => 1, 'maxX' => 400, 'minY' => 1, 'maxY' => 400);$mapArray = array(); //array with the map$viewX = 0; //X and Y which will be displayed on map$viewY = 0;$tileWidth = 70;$tileHeight = 34;$mapWidth = 15;$mapHeight = 15;$startX = $myX - $mapWidth / 2;$endX = $myX + $mapWidth / 2;$startY = $myY - $mapHeight / 2;$endY = $myY + $mapHeight / 2;$xOffset = ($tileWidth * $mapWidth) / 2; //center the first tile$yOffset = 20; //put the map a bit lower$avaliableTiles = array( 'town1', 'town2', 'plain');$lineNumber = 1;$sql = "SELECT users.username as owner , towns.townname as town ,towns.x as x,towns.y as y,towns.points as points, towns.picture as picture "."FROM users INNER JOIN towns ON(users.id = towns.user_id) "."WHERE towns.x BETWEEN ".$startX." AND ".$endX." "."AND towns.y BETWEEN ".$startY." AND ".$endY ." ";$sql = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($sql)){$mapArray[$row['y']][$row['x']] = array('owner' => $row['owner'],'townname'=> $row['townname'],'points'=>$row['points'],'picture'=>$row['picture'])}for ($y = ceil($startY); $y < ceil($endY); $y++) { for ($x = ceil($startX); $x < ceil($endX); $x++) { $viewX = $x; //View X and ViewY are the true X and Y Coordinates $viewY = $y; if ($x < $mapLimit['minX']) { $viewX = $mapLimit['maxX'] + $x; } if ($x > $mapLimit['maxX']) { $viewX = $mapLimit['minX'] - $x; } if ($y < $mapLimit['minY']) { $viewY = $mapLimit['maxY'] + $y; } if ($y > $mapLimit['maxY']) { $viewY = $mapLimit['minY'] - $y; } $map .= '<div class="tile ' . $mapArray[$viewY][$viewX]['picture'] . '" style="color:' . $color . ';top:' . round($yOffset) . 'px;left:' . round($xOffset) . 'px;">Y' . $viewY. '/X' . $viewX . '</div>'; $yOffset += $tileHeight / 2; $xOffset += $tileWidth / 2; } $xOffset = ($tileWidth * $mapWidth) / 2 - $tileWidth / 2 * $lineNumber; //the new line starts again from center - half tilewidth * linenumber $yOffset = 20 + $tileHeight / 2 * $lineNumber; $lineNumber++;}$step = (isset($_GET['step']) ? $_GET['step'] : 1);$directions = array( 'w' => array('x' => $myX, 'y' => $myY + $step), 's' => array('x' => $myX + $step, 'y' => $myY), 'e' => array('x' => $myX, 'y' => $myY - $step), 'n' => array('x' => $myX - $step, 'y' => $myY),);?><a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['w']['y'], $directions['w']['x'], $step) ?>">West</a><a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['s']['y'], $directions['s']['x'], $step) ?>">South</a><a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['n']['y'], $directions['n']['x'], $step) ?>">North</a><a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['e']['y'], $directions['e']['x'], $step) ?>">East</a><?= $map ?>
and please help jack instead of sayin somethink about my mistakes;) iam not who want to have a Diamond Iso Map
I am still trying to figure out how to fix the link problem.
about the server thing i use purchased hosting at hosting24.com so i can't pick what computer gets used but i do have a lot of freedom.and my thoughts for the server thing was:with my website i have, my hosting service lets me add as many sub links as i wantso for the server i could do S1-Medieval-Europe.medieval-wars-online.comwhat would be bad about doing multible servers that way and also im not planning to have more then 1 server till the first gets over 1000 players which i dubt will happen