Hello dear programmers . i am developing an online mmorpg game . so speed is very important . i have a complex map system which is coded by me . at this map system for walking i am using ajax .
using iis 7.5 and netframework 3.5 .
at this page you can use w,a,s,d or keyboard arrow keys for walking
http:// www.pokemoncraft.com/gamepage.aspx ( username : test1234 , password : test1234 )
as you can see at image below when a player pushes the movement buttons faster ( without waiting to move completed ) status being aborted so it really prevents walking faster
i want to prevent this is from happening ( disable buttons to be pushed so fast until post event completed )
http://img716.imageshack.us/img716/2168/abortedd.png
these values obtained with firefox - firebug
here what happens when you push keyword buttons for moving
i appreciate any help thank you
<script type="text/javascript">
document.onkeydown = cancelArrowKeys;
function cancelArrowKeys(e) {
try {
var e = window.event || e
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
if (key == 37 || key == 38 || key == 39 || key == 40 || key == 13 || key==65 || key==87 || key==68 || key==83) {
if (key == 13)
document.getElementById('<%=btnFightPokemon.ClientID%>').click();
if (key == 37 || key == 65)
{
document.getElementById('<%=btnHiddenWest.ClientID%>').click();
}
if (key == 38 || key == 87)
{
document.getElementById('<%=btnHiddenNorth.ClientID%>').click();
}
if (key == 39 || key == 68)
{
document.getElementById('<%=btnHiddenEast.ClientID%>').click();
}
if (key == 40 || key == 83)
{
document.getElementById('<%=btnHiddenSouth.ClientID%>').click();
}
event.returnValue = false;
}
}
catch (Exception) {
return false;
}
}
var k = 0;
function moveLeft() {
try {
document.getElementById('<%=btnHiddenWestMulti.ClientID%>').click();
}
catch (Exception) {
return false;
}
}
function moveRight() {
try {
document.getElementById('<%=btnHiddenEastMulti.ClientID%>').click();
}
catch (Exception) {
return false;
}
}
function moveUp() {
try {
document.getElementById('<%=btnHiddenNorthMulti.ClientID%>').click();
}
catch (Exception) {
return false;
}
}
function moveDown() {
try {
document.getElementById('<%=btnHiddenSouthMulti.ClientID%>').click();
}
catch (Exception) {
return false;
}
}