[quote]<?php
session_start();
mysql_connect('localhost', 'root', '');
mysql_select_db('jeu');
$req1 = mysql_query("SELECT * FROM membre WHERE login = '".$_SESSION['login']."'");
$data1 = mysql_fetch_array($req1);
?>
<?
$vision = $data1['vision'];
$x = $data1['x']; //récupération de l'abscisse du perso
$y = $data1['y']; //récupération de l'ordonnée du perso
$compteurX = $x - $vision; //champ de vision
$compteurY = $y - $vision; //champ de vision
$finX = $x + $vision; //champ de vision
$finY = $y + $vision; //champ de vision
$debutX = $x - $vision;
echo '<table cellspacing="0" cellpadding="0">';
//----------------- UNE LIGNE -----------------\\
while($compteurY <= $finY)
{
echo "<tr>";
//----------------- UNE CASE -----------------\\
while($compteurX <= $finX)
{
$req2 = mysql_query("SELECT terrain FROM batiments WHERE x='".$compteurX."' AND y='".$compteurY."'");
if(mysql_num_rows($req2) == 1) //s'il y a un bâtiment, on sélectionne la couleur de son terrain
{
$data2 = mysql_fetch_array($req2);
if($mois == 12 OR $mois == 01 OR $mois == 02) //si on est en hiver
{
switch($data2['terrain'])
{
case "4425544":
$rgb = "127255127";
break;
case "178178178":
$rgb = "188188188";
break;
case "132193136":
$rgb = "182218185";
break;
case "01060":
$rgb = "4920449";
break;
case "1060106":
$rgb = "19896253";
break;
case "962626":
$rgb = "19210101";
break;
default:
$rgb = $data2['terrain'];
}
}
else
{
$rgb = $data2['terrain'];
}
}
else //sinon on sélectionne la couleur du terrain via le pixel correspondant
{
$image = ImageCreateFromPng("Europe_1205_ete.png");
$rgb = ImageColorAt($image, $compteurX, $compteurY); //on identifie la couleur du pixel donné à partir de ses coordonnées <--- LIGNE 74
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$rgb = $r.$g.$b; //couleur RGB du pixel
}
$col = array(
"4425544" => "herbe.gif", "127255127" => "herbe.gif", "138138138" => "herbe.gif", "178178178" => "herbe.gif",
"188188188" => "herbe.gif", "132193136" => "contrees.gif", "182218185" => "herbe.gif", "25500" => "hebre.gif",
"0231231" => "herbe.gif", "44113255" => "herbe.gif", "1361360" => "herbe.gif", "01060" => "herbe.gif",
"4920449" => "herbe.gif", "1060106" => "herbe.gif", "19896253" => "herbe.gif",
"962626" => "herbe.gif", "192101101" => "herbe.gif", "255255255" => "herbe.gif",
"000" => "herbe.gif", "12812864" => "herbe.gif", "255255128" => "herbe.gif", "0168168" => "herbe.gif",
"229229229" => "herbe.gif");
?>
<td onMouseout='infoterrain("rien")' onMouseover='infoterrain("<? echo $rgb; ?>")' valign='center' style='text-align:center;width:60px;height:60px;background-color:RGB("<? echo $r; ?>","<? echo $g; ?>","<? echo $b; ?>");background-image:url("<? echo $col[$rgb]; ?>");width:60px;height:60px'>
<?
$req3 = mysql_query("SELECT * FROM membre WHERE x='".$compteurX."' AND y='".$compteurY."'");
if(mysql_num_rows($req3) == 1) //s'il y a un personnage
{
$data3 = mysql_fetch_array($req3);
$req3bis = mysql_query("SELECT * FROM membre WHERE login='".$data3['login']."'");
$data3bis = mysql_fetch_array($req3bis);
if($compteurX == $x AND $compteurY == $y)
{
?>
<div style="width:60px;height:60px;overflow:hidden">
<div style="
text-align: left;
font-size: 12px;
font-family: Arial, 'Times New Roman';
width: 300px;
height: 200px;
border-top: 1px solid white;
border-left: 1px solid white;
border-right: 1px solid black;
border-bottom: 1px solid black;
left: 387px;
top: 436px;
z-index: 1;
background-image: url('');
visibility: hidden;
position: absolute;
overflow: auto;
padding:4px" id="<? echo $data3['id']; ?>">
<p style="font-size:14px;color:white;font-weight:bold"><? echo $data3['login']; ?></p>
<p style="color:white" class="donnees">Rang : <? echo $data3bis['grade']; ?><br />
Pays : <? echo $data3bis['Royaume']; ?><br />
Fief : <? echo $data3bis['Race']; ?></p>
<p style="text-align:center"><input type="submit" class="submit" value="Accéder au profil"></p>
<p style="color:white"><a style="color:white;cursor:pointer" onClick="MM_showHideLayers('<? echo $data3['id']; ?>','','hide')">Fermer l'onglet</a></p>
</div>
<img width="60" height="60" alt="Vous-même" title="Vous-même" src="<? echo $data3['skin']; ?>" style="cursor:default" border="0" onclick="MM_showHideLayers('<? echo $data3['id']; ?>','','show')"></div>
<? } //vous-même
elseif($compteurX == $data3['x'] AND $compteurY == $data3['y'])
{
?>
<div style="width:60px;height:60px;overflow:hidden">
<div style="
text-align: left;
font-size: 12px;
font-family: Arial, 'Times New Roman';
width: 300px;
height: 200px;
border-top: 1px solid white;
border-left: 1px solid white;
border-right: 1px solid black;
border-bottom: 1px solid black;
left: 387px;
top: 436px;
z-index: 1;
background-image: url('');
visibility: hidden;
position: absolute;
overflow: auto;
padding:4px" id="<? echo $data3['id']; ?>">
<p style="font-size:14px;color:white;font-weight:bold"><? echo $data3['login']; ?></p>
<p style="color:white" class="donnees">Rang : <? echo $data3bis['grade']; ?><br />
Pays : <? echo $data3bis['Royaume']; ?><br />
Fief : <? echo $data3bis['race']; ?></p>
<p style="text-align:center"><input type="submit" class="submit" value="Accéder au profil"></p>
<p style="color:white"><a style="color:white;cursor:pointer" onClick="MM_showHideLayers('<? echo $data3['id']; ?>','','hide')">Fermer l'onglet</a></p>
</div>
<img width="60" height="60" alt="<? echo $data3['login']; ?>" title="<? echo $data3['login']; ?>" src="<? echo $data3['skin']; ?>" style="cursor:default" border="0" onclick="MM_showHideLayers('<? echo $data3['id']; ?>','','show')"></div>
<?
} //les autres personnages
}
else //s'il n'y a pas de personnage
{
$req4 = mysql_query("SELECT * FROM batiments WHERE x='".$compteurX."' AND y='".$compteurY."'");
if(mysql_num_rows($req4) == 1)//s'il y a un bâtiment
{
$data4 = mysql_fetch_array($req4);
?>
<div title="<? echo $data4['batiment']; ?>" style="width:60px;height:60px;background-image:url('<? echo $data4['skin']; ?>')" onclick="MM_showHideLayers('<? echo $data4['id']; ?>','','show')">
<div style="
text-align: left;
font-size: 12px;
font-family: Arial, 'Times New Roman';
width: 300px;
height: 200px;
border-top: 1px solid white;
border-left: 1px solid white;
border-right: 1px solid black;
border-bottom: 1px solid black;
left: 387px;
top: 436px;
z-index: 1;
background-image: url('');
visibility: hidden;
position: absolute;
overflow: auto;
padding:4px" id="<? echo $data4['id']; ?>">
<p style="font-size:14px;color:white;font-weight:bold"><? echo $data4['batiment']; ?></p>
<p style="color:white;font-size:11px"><? echo $data4['description']; ?></p>
<p style="color:white"><a style="color:white;cursor:pointer" onClick="MM_showHideLayers('<? echo $data4['id']; ?>','','hide')">Fermer l'onglet</a></p>
</div>
<?
$reqmag = mysql_query("SELECT * FROM magasin WHERE batiment='".$data4['skin']."'");
if(mysql_num_rows($reqmag) == 1)
{
$mag = mysql_fetch_array($reqmag);
?><img src="<? echo $mag['enseigne']; ?>">
<?
}
echo'</div>';
}
else //s'il n'y a ni personnage, ni bâtiment
{
$req5 = mysql_query("SELECT * FROM monstres WHERE x='".$compteurX."' AND y='".$compteurY."'");
if(mysql_num_rows($req5) == 1) //s'il y a un monstre
{
$data5 = mysql_fetch_array($req5);
echo '<img src="'.$data5['skin'].'" alt="'.$data5['skin'].'" title="'.$data5['skin'].'" style="cursor:help" width="60" height="60">';
}
else //s'il n'y a ni personnage, ni monstre, ni bâtiment
{
$x1 = $x + 1;
$y1 = $y + 1;
$x_1 = $x - 1;
$y_1 = $y - 1;
if($rgb == "0231231" OR $rgb == "1361360" OR $rgb == "44113255" OR $rgb == "000"){ echo '<div align="center" style="width:60px;height:60px"> </div>';} //terrains inacessibles
else //si c'est un terrain accessible
{