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

2015/6/10

Need help testing if actor is moving towards something

ArrogantMagician ArrogantMagician

2015/6/10

#
I want to make a shadow on a actor elongate when it moves away from another actor (and vise versa), but I don't know what could test if it is moving away. I've got this code, but it doesn't tell me if the actor is getting further away:
List<Light>objects = getObjectsInRange(600, Light.class);
I am thinking the code would be like "if(actors distance to object is decreasing){ elongation += 1; } Any ideas?
danpost danpost

2015/6/10

#
I think the angle between the two actors would be as important as the distance. The angle would determine the shape of the shadow (angle and direction) and the distance and intensity of the light would determine the density of the shadow. Do not think of it as increasing or decreasing, but as what it would be like at any particular instance in time.
You need to login to post a reply.