Re: Retro RPG/MUD
Posted: Fri Nov 06, 2009 7:18 pm
ugh blaahaha this is a struggle.
this is a snippet of the movement code and tryinh to make collisions to work
i finally got the php array that holds all locations for x number of trees into JS but left and top have px in it. So no way of comparing the two. I need to think of an alternative. Not only that its going to massive coding adding each image height and width to the top and left then checking each type of image. My god so much coding 
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();
}