Quote:
Originally Posted by Switch
Couldn't something like this be a workaround? Maybe have distances for each baddy?
PHP Code:
//baddy.x+1.5 and baddy.y+2 for center if using regular character height/width
if (player.ani == "my_run") {
if (player.x in |baddy.x+1.5-15, baddy.x+1.5+15| && player.y in |baddy.y+2-15, baddy.y+2+15|) {
//stuffz
}
}
else if (player.ani == "my_walk") {
if (player.x in |baddy.x+1.5-10, baddy.x+1.5+10| && player.y in |baddy.y+2-10, baddy.y+2+10|) {
//stuffz
}
}
else if (player.ani == "my_creep") {
if (player.x in |baddy.x+1.5-5, baddy.x+1.5+5| && player.y in |baddy.y+2-5, baddy.y+2+5|) {
//stuffz
}
}
|
It's usually best to just use the distance rather than trying to check a certain box.
PHP Code:
// adding 3 to both; assuming player and NPC are 3x3 tiles so + 1.5 + 1.5
temp.distance = (((player.x - this.x + 3) ^ 2) + ((player.y - this.y + 3) ^ 2)) ^ 0.5;
if (distance < 5) {
// whatever
}