Thread: Detecting Sound
View Single Post
  #11  
Old 03-10-2010, 11:36 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Switch View Post
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-15baddy.x+1.5+15| && player.y in |baddy.y+2-15baddy.y+2+15|) {
    
//stuffz
  
}
}
else if (
player.ani == "my_walk") {
  if (
player.x in |baddy.x+1.5-10baddy.x+1.5+10| && player.y in |baddy.y+2-10baddy.y+2+10|) {
    
//stuffz
  
}
}
else if (
player.ani == "my_creep") {
  if (
player.x in |baddy.x+1.5-5baddy.x+1.5+5| && player.y in |baddy.y+2-5baddy.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.this.3) ^ 2) + ((player.this.3) ^ 2)) ^ 0.5;

if (
distance 5) {
  
// whatever

__________________
Reply With Quote