# hitTest trouble... please help!

**URL:** <https://forum.kirupa.com/t/hittest-trouble-please-help/41504>\
**Category:** programming\
**Created:** [January 29, 2004, 10:59pm UTC](https://forum.kirupa.com/t/hittest-trouble-please-help/41504 "2004-01-29T22:59:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alzor](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@alzor](https://forum.kirupa.com/u/alzor)\
**Post date:** [January 29, 2004, 10:59pm UTC](https://forum.kirupa.com/t/hittest-trouble-please-help/41504/1 "2004-01-29T22:59:36Z")

</div>

having trouble…

the hitTest down at the bottom of this code doesnt seem to work, I want to make it so that when the dot hits the player, the dot doesnt go any further… Ive tried a number of things other than this and they dont work either. any help would be greatly appreciated. thanks…

onClipEvent (load){  
var xspeed, yspeed;  
xspeed = math.random()\*5;  
yspeed = math.random()\*5;  
\_x=0;  
\_y=0;  
y = this.\_y;  
x = this.\_x;  
playerx= player.\_x;  
playery= player.\_y;  
}

onClipEvent (enterFrame){  
this.\_x+= xspeed;  
this.\_y+= yspeed;  
if (this.\_x \> 550 or this.\_x \< 0 ){  
xspeed \*= -1;  
}  
if (this.\_y \> 400 or this.\_y \< 0 ){  
yspeed \*= -1;  
}  
if (this.\_y \> 400 and this.\_x \> 550 or this.\_y\>400 and this.\_x\<0){  
yspeed \*= -1;  
xspeed \*= -1;  
}  
// if dude is walking toward upper right  
if (this.\_x \<= +250 and this.\_y \>= +200){  
this.\_rotation = 45;  
}  
else if (this.\_x \>= +250 and this.\_y \<+200){  
this.\_rotation = 225;  
}  
else if (this.\_x \<= +250 and this.\_y \<+200){  
this.\_rotation = 135;  
}

// this part doesnt seem to work…  
if (this.hitTest(\_root.player)){  
this.\_x+= 0;  
this.\_y+= 0;  
}  
}
