Quote:
|
Originally Posted by Shaun
Not quite...
onwall2(x,y,width,height) returns a boolean value (true or false value).
So if you wanted to see if the left side of a player was blocking, for example, it would look something like this:
if (onwall2(player.x,player.y+1,1/16,2)==true) {
player.blockleft = true;
}
else {
player.blockleft = false;
}
|
a little bit of redundancy here.
onwall2(player.x,player.y+1,1/16,2)==true
true == true returns true
false == true returns false
so you can just do: if (onwall2(x,y,w,h))
otherwise it would be doing a double comparison, which should be avoided, although it really won't matter much unless you're doing a long for loop or something.