I am creating small game where my object move left and right with arrow keys but that movement is not fast and not even interactive,its like when i press key object move bit later. Any one can suggest how i could make it better in terms of user experience.
here is part of my code that control moving objects(Its two player game so arrow keys for one and A W D for second)
$(document).keydown(function(e){
switch(e.keyCode){
//Move left
case 37:
$('.playerOne').stop().animate({"left":"-=15px"}, '1000', 'linear');
return false;
break;
//Move right
case 39:
$('.playerOne').stop().animate({"left":"+=15px"}, '1000', 'linear');
return false;
break;
//Shoot
case 38:
shotEffect(1,'hitOne','bottom','playerOne');
break;
//Move right
case 68:
$('.playerTwo').stop().animate({"left":"+=15px"}, '1000', 'linear');
return false;
break;
//Move left
case 65:
$('.playerTwo').stop().animate({"left":"-=15px"}, '1000', 'linear');
return false;
break;
//Shoot
case 87:
shotEffect(1,'hitTwo','top','playerTwo');
break;
}
});
Thanks in advance