Jump to content

[Problems]walking on ground javascript


Recommended Posts

hi dev i have problems on walking character on ground as I let the key figure continues on

someone can litle help? i know i must add keyup but where 

$(document).ready(function(){

	$("div#l").click(function(){
				wyslij('lewo',8,0,1);
	});
	$("div#p").click(function(){
				wyslij('prawo',-8,0,2);
	});
	$("div#g").click(function(){
	
				wyslij('gora',0,8,3);
	});
	$("div#d").click(function(){
				wyslij('dol',0,-8,0);
	});
	$("div#oHero").click(function(){
	});

	 $(document).keydown(function (event) {
				if(event.keyCode==65 && chatmode==0){$("div#l").click();}
				if(event.keyCode==87 && chatmode==0){$("div#g").click();}
				if(event.keyCode==68 && chatmode==0){$("div#p").click();}
				if(event.keyCode==83 && chatmode==0){$("div#d").click();}					
	});
});

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");
}
  // GOOD GAME 
Link to comment
Share on other sites

  • Replies 11
  • Created
  • Last Reply

Top Posters In This Topic

What do you want to do?

 

A little more description and an example could be useful.

 

Kind regards

Chuck 

my script 

var loading = false;
$(document).ready(function(){

$("div#l").click(function(){
send('left',8,0,1);
});
$("div#p").click(function(){
send('right',-8,0,2);
});
$("div#g").click(function(){

send('up',0,8,3);
});
$("div#d").click(function(){
send('down',0,-8,0);
});
$("div#oHero").click(function(){
});

$(document).keydown(function (event) {
if(event.keyCode==65 && chatmode==0){send('left',8,0,1);}
if(event.keyCode==87 && chatmode==0){send('up',0,8,3);}
if(event.keyCode==68 && chatmode==0){send('right',-8,0,2);}
if(event.keyCode==83 && chatmode==0){send('down',0,-8,0);}	
});
});

function send(page,ox,oy,direction){
if(loading) return false;
loading = true;
$.ajax({
type: "POST",
url: "system/idz.php",
data:"move="+page,
success : function (msg){
loading = false;
if (msg){
$('#oMap').css("background-image","url("+msg+")");
setTimeout("map_poz(x+="+ox+",y+="+oy+");animation(0,"+direction+");",10);
setTimeout("map_poz(x+="+ox+",y+="+oy+");animation(1,"+direction+");",20);
setTimeout("map_poz(x+="+ox+",y+="+oy+");animation(2,"+direction+");",30);
setTimeout("map_poz(x+="+ox+",y+="+oy+");animation(3,"+direction+");",40);
setTimeout("animation(0,"+direction+");",50);
}

}
});
}

function map_poz(x,y){
$("#oMap").css("background-position", x+"px "+y+"px");
}
function animation(cage,direction){
$("#oHero").css("background-position",(-cage*32)+"px "+(-direction*48)+"px");
}
// GOOD GAME

how to slow walking and fix Turn character go upwards and wants to turn into the side of it for a moment I can not move

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.