when running this code:
var monsterPos = [0];
var monsterList= [0];
var singleMonster = [0];
var frame = 0;
var isAttacking = false;
var listener = new window.keypress.Listener();
// var l = 1;
function monsterLister(element)//currently not in use
{
singleMonster = getPosition($(this));
monsterPos[monsterPos.length] = singleMonster.x;
monsterList[monsterList.length] = l;
l++;
}
function moveRight3()
{
frame = (frame+1)%4;
if (!isAttacking) {$("#hero").attr("src","move"+(frame+1)+".png");}
$('.monster').each(function(index, img){$(this).css("left", (parseInt($(this).css("left")) - 40))});
}
function attack1(event)
{
if ((($(this)).keyCode) == 65){
isAttacking = true;
for (q=0, len = monsterPos.length; len > q; q++){
if (400 > monsterPos[q] > 560){
$("monsterList["+q+"]").css(opacity, 0);
}}
$("#hero").attr("src","attack.png");
console.log("attack");
}}
listener.register_combo({
"keys" : "a",
"on_keydown" : function(){$("#hero").attr("src","attack.png");
isAttacking = true;
for (q=0, len = monsterPos.length; len > q; q++){
if (400 > monsterPos[q] > 560){
$("monsterList["+q+"]").css(opacity, 0);
}
}
},
on_keyup : function(){isAttacking = false;}
});
when running this code: var monsterPos = [0]; var monsterList= [0]; var singleMonster = [0]; var frame = 0; var isAttacking = false; var listener = new window.keypress.Listener(); // var l = 1;
$(document).ready(function() { setInterval(moveRight3, 100);
});
function getPosition(element) { var xPosition = 0; var yPosition = 0;
}
function monsterLister(element)//currently not in use { singleMonster = getPosition($(this)); monsterPos[monsterPos.length] = singleMonster.x; monsterList[monsterList.length] = l; l++; }
function moveRight3() { frame = (frame+1)%4; if (!isAttacking) {$("#hero").attr("src","move"+(frame+1)+".png");} $('.monster').each(function(index, img){$(this).css("left", (parseInt($(this).css("left")) - 40))}); }
function attack1(event) { if ((($(this)).keyCode) == 65){ isAttacking = true; for (q=0, len = monsterPos.length; len > q; q++){ if (400 > monsterPos[q] > 560){ $("monsterList["+q+"]").css(opacity, 0); }} $("#hero").attr("src","attack.png"); console.log("attack");
}}
listener.register_combo({ "keys" : "a", "on_keydown" : function(){$("#hero").attr("src","attack.png"); isAttacking = true; for (q=0, len = monsterPos.length; len > q; q++){ if (400 > monsterPos[q] > 560){ $("monsterList["+q+"]").css(opacity, 0); } } }, on_keyup : function(){isAttacking = false;} });