probs /w browser compatibility and little help
Posted: Mon Nov 04, 2002 10:03 am
I'm making an online MMORTS (real time strat) game using php and mysql. It's for my thesis... duh. I'm ditching NS4.. good desicion?
___________________________________________
Does anyone still use NS6? NS4? I got probs with it. It doesn't display table background image as IE/opera does. It tiles the background image according to the cell size unlike in IE where the whole image is shown.
__________________________________________
Also, how do I change background in javascript? here's my code
var i = new Image();
i.src = "hl.png";
>then on mouse over...
this.background.src=i; (doesn't work for me)
any code that'll work on IE 5 above, Opera 5 above and NS6?
___________________________________________
how do I change cursor in NS6 and Opera5? this works for IE5 and IE6.
function overmove(o,x,y) {
over(o);
o.style.cursor="hand";
}
____________________________________________
any way to change opacity for NS6 and Opera 5? my code that works for IE is
obj.style.filter="alpha(opacity="+opacity+")";
____________________________________________
Do php gurus use OOP? Another thing that i'm concerned about is that i might be programming in a bad way. here's most of my code. Can anyone look at it for a minute and tell me how i'm doing? BTW, where can I get the latest javascript reference for ns6, ie6 and opera? Thanks!
___________________________________________
Does anyone still use NS6? NS4? I got probs with it. It doesn't display table background image as IE/opera does. It tiles the background image according to the cell size unlike in IE where the whole image is shown.
__________________________________________
Also, how do I change background in javascript? here's my code
var i = new Image();
i.src = "hl.png";
>then on mouse over...
this.background.src=i; (doesn't work for me)
any code that'll work on IE 5 above, Opera 5 above and NS6?
___________________________________________
how do I change cursor in NS6 and Opera5? this works for IE5 and IE6.
function overmove(o,x,y) {
over(o);
o.style.cursor="hand";
}
____________________________________________
any way to change opacity for NS6 and Opera 5? my code that works for IE is
obj.style.filter="alpha(opacity="+opacity+")";
____________________________________________
Do php gurus use OOP? Another thing that i'm concerned about is that i might be programming in a bad way. here's most of my code. Can anyone look at it for a minute and tell me how i'm doing? BTW, where can I get the latest javascript reference for ns6, ie6 and opera? Thanks!
Code: Select all
$query = ' SELECT locx,locy from players where name="Miguel"';
$result = mysql_query($query, $connection) or die(error('Connection failed!'));
// place x,y coords from query result to $x and $y and convert to integer
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
$locx = $rowї0] + 0;
$locy = $rowї1] + 0;
}
if($x < 1 || $y < 1 || $x < $locx-2 || $x > $locx+2 || $y < $locy-2 || $y > $locy+2)
{ // If player had just started game or when move is invalid
$x = $locx;
$y = $locy;
}
else // Move is valid. Update DB.
{
$query = ' UPDATE players set locx=' . $x . ', locy='. $y .' where name="Miguel"';
$result = mysql_unbuffered_query($query, $connection) or die(error('Connection failed!'));
}
// Get critters around area
$query = 'SELECT locx,locy FROM critters WHERE locx > ' . ($x-5) . ' AND locx < ' . ($x+6) . ' AND locy > ' . ($y-5) . ' AND locy < ' . ($y+6);
$result = mysql_query($query, $connection) or die(error($query));
$critters = array_fill(0,81,0);
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
for($ey=$y-4,$a=0;$ey!=$y+5;$ey++)
for($ex=$x-4;$ex!=$x+5;$ex++,$a++)
if($rowї0] == $ex && $rowї1] == $ey)
$crittersї$a]++;
}
// Get players around area
$query = 'SELECT locx,locy FROM characters WHERE locx > ' . ($x-5) . ' AND locx < ' . ($x+6) . ' AND ly > ' . ($y-5) . ' AND locy < ' . ($y+6) . ' AND name NOT LIKE "yogi bear"';
$result = mysql_query($query, $connection) or die(error($query));
$players = array_fill(0,81,0);
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
for($ey=$y-4,$a=0;$ey!=$y+5;$ey++)
for($ex=$x-4;$ex!=$x+5;$ex++,$a++)
if($rowї0] == $ex && $rowї1] == $ey)
$playersї$a]++;
}
mysql_free_result($result);
mysql_close($connection);
// TABLES
echo '<table cellpadding=0 cellspacing=0 border=0><tr><TD valign=top><font size=2>
MAP: Grassy Plains (' . $x . ',' . $y . ')<p>
Allies:<p>Opponent:<p>Critters:</font></td><td><br>
<table cellpadding=0 cellspacing=0 border=0><tr><td>
<table cellpadding=0 cellspacing=0 border=0><tr height=18>';
for($ex=$x-5;$ex!=$x+5;$ex++)
{
if($ex==$x-5)
echo '<td width=18></td>';
else if($ex%2==0)
echo '<td width=18 bgcolor=#5B5B5B ALIGN=center>'.$ex.'</td>
';
else
echo '<td width=18 align=center>'.$ex.'</td>';
}
echo '</tr></table></td></tr><TR><td><table cellpadding=0 cellspacing=0
border=0><tr><TD><table cellpadding=0 cellspacing=0 border=0 width=18>';
for($ey=$y-4;$ey!=$y+5;$ey++)
{
if($ey%2!=0)
echo '<tr><td height=18 bgcolor=#5B5B5B align=center>'.$ey.'</td>';
else
echo '<tr><td height=18 align=center>'.$ey.'</td></tR>';
}
echo '</table></td><td><table cellpadding=0 cellspacing=0 border=0 background="images/bg.png" id="link_table">';
for($ey=$y-4,$a=0;$ey!=$y+5;$ey++) {
echo '<tr height=18>';
for($ex=$x-4;$ex!=$x+5;$ex++,$a++) {
echo '<TD width=18 ';
if($ex>$x-3 && $ex<$x+3 && $ey>$y-3 && $ey<$y+3)
echo 'onMouseOver="overmove(l' . $ex . 'l'. $ey . ')" onClick="clickMove(' . $ex . ',' . $ey . ')" ';
else
echo 'onMouseOver="over(l' . $ex .'l'. $ey . ')" ';
if($crittersї$a]>0)
echo 'background="oppoicon.png"';
else if($ex == $x && $ey == $y)
echo 'background="me.png"';
echo ' onMouseOut="out(l' . $ex . 'l' . $ey . ')"><img src=hl.png id="l'. $ex . 'l'.$ey.'" style="visibility:hidden"></td>';
}
echo '</tr>';
}
echo '</table></td></tr></table></td></tr></table>';
?>