this is a snippet of the movement code and tryinh to make collisions to work
Code: Select all
function keyListener(e){
if(!e){
//for IE
e = window.event;
}
//////////////////////////////////////////////////west(left)//////////////////////////////////
if(e.keyCode==65 && playerLeft > 5){
//keyCode 37 is left arrow
////////////////collison//////////////////
for(i=treeamount;k>0;k=k-1)
{
if (eval(tree+k).style.left < player.style.left);
{collision = 1;}
}
if (collision != 1){
playerLeft -= 8;
player.style.left = playerLeft + 'px';
}
movewest();
}