div-map.php
<?php require_once('../php/mysql-connect.php'); $ajax_txt = ""; $poz_x = ((-$postac['x']) * 32) + 240; $poz_y = ((-$postac['y']) * 32) + 240; $ajax_txt .= "".$poz_x."px ".$poz_y."px"; exit; ?>
js:
<script> function wyslij(strona,ox,oy,kierunek){ $.ajax({ type: "POST", url: "js/idz.php", data:"move="+strona, success: function(msg){ if(msg){ $('#oMap').css("background-image","url("+msg+")"); setTimeout("map_poz(x+="+ox+",y+="+oy+");animation(0,"+kierunek+");",100); setTimeout("map_poz(x+="+ox+",y+="+oy+");animation(1,"+kierunek+");",200); setTimeout("map_poz(x+="+ox+",y+="+oy+");animation(2,"+kierunek+");",300); setTimeout("map_poz(x+="+ox+",y+="+oy+");animation(3,"+kierunek+");",400); setTimeout("animation(0,"+kierunek+");",500); } } }); function map_poz(x,y){ $("#oMap").css("background-position", x+"px "+y+"px"); } function animation(klatka,kierunek){ $("#oHero").css("background-position",(-klatka*32)+"px "+(-kierunek*48)+"px"); } </script>
idz.php
<?php require_once('../php/mysql-connect.php'); require_once('../php/load-data.php'); if($postac['zycie'] > 0){ $teleport = mysql_fetch_array(mysql_query("select * from mapa_przenies where mapa = ".$postac['mapa']." and x = ".$postac['x']." and y = ".$postac['y']." limit 1")); if($_POST['move'] == 'lewo'){ $npcblock = mysql_fetch_array(mysql_query("select * from npc where mapa = ".$postac['mapa']." and x = ".($postac['x'] - 1)." and y = ".$postac['y']." limit 1")); $npcblock2 = mysql_fetch_array(mysql_query("select * from mob where mapa = ".$postac['mapa']." and x = ".($postac['x'] - 1)." and y = ".$postac['y']." and respawn <= ".$czas_ogolny." limit 1")); $blokada = mysql_fetch_array(mysql_query("select * from blokadaprzejscia where mapa = ".$postac['mapa']." and x = ".($postac['x'] - 1)." and y = ".$postac['y']." limit 1")); $postac['x'] -= 1; exit; } } if($_POST['move'] == 'prawo'){ $npcblock = mysql_fetch_array(mysql_query("select * from npc where mapa = ".$postac['mapa']." and x = ".($postac['x'] + 1)." and y = ".$postac['y']." limit 1")); $npcblock2 = mysql_fetch_array(mysql_query("select * from mob where mapa = ".$postac['mapa']." and x = ".($postac['x'] + 1)." and y = ".$postac['y']." and respawn <= ".$czas_ogolny." limit 1")); $blokada = mysql_fetch_array(mysql_query("select * from blokadaprzejscia where mapa = ".$postac['mapa']." and x = ".($postac['x'] + 1)." and y = ".$postac['y']." limit 1")); mysql_query("update postac set x = x + 1 where id = ".$postac['id']." and x < ".$mapa['maks_x']." limit 1"); $postac['x'] += 1; exit; } } if($_POST['move'] == 'gora'){ $npcblock = mysql_fetch_array(mysql_query("select * from npc where mapa = ".$postac['mapa']." and x = ".$postac['x']." and y = ".($postac['y'] - 1)." limit 1")); $npcblock2 = mysql_fetch_array(mysql_query("select * from mob where mapa = ".$postac['mapa']." and x = ".$postac['x']." and y = ".($postac['y'] - 1)." and respawn <= ".$czas_ogolny." limit 1")); $blokada = mysql_fetch_array(mysql_query("select * from blokadaprzejscia where mapa = ".$postac['mapa']." and x = ".$postac['x']." and y = ".($postac['y'] - 1)." limit 1")); $postac['y'] -= 1; exit; } } if($_POST['move'] == 'dol'){ $npcblock = mysql_fetch_array(mysql_query("select * from npc where mapa = ".$postac['mapa']." and x = ".$postac['x']." and y = ".($postac['y'] + 1)." limit 1")); $npcblock2 = mysql_fetch_array(mysql_query("select * from mob where mapa = ".$postac['mapa']." and x = ".$postac['x']." and y = ".($postac['y'] + 1)." and respawn <= ".$czas_ogolny." limit 1")); $blokada = mysql_fetch_array(mysql_query("select * from blokadaprzejscia where mapa = ".$postac['mapa']." and x = ".$postac['x']." and y = ".($postac['y'] + 1)." limit 1")); mysql_query("update postac set y = y + 1 where id = ".$postac['id']." and y < ".$mapa['maks_y']." limit 1"); $postac['y'] += 1; exit; } } } exit; ?>