This site requires JavaScript, please enable it in your browser!
Greenfoot back
Canning
Canning wrote ...

2011/9/10

Distance

Canning Canning

2011/9/10

#
I am wanting to create a method that has 2 actors as parameters and calculates the distance between the two actors. Is there a sample of this that I can have a look at? thanks Canning
bourne bourne

2011/9/10

#
All you need is the distance formula and the actor location accessor methods, public double findDistanceBetween(Actor a1, Actor a2) { return Math.sqrt(Math.pow(a1.getX() - a2.getX(), 2) + Math.pow(a1.getY() - a2.getY(), 2)); }
Canning Canning

2011/9/10

#
Thanks bourne
You need to login to post a reply.