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

2022/5/23

I need help with a code!

ELquenosabena ELquenosabena

2022/5/23

#
I need the actor("enemy"), that when I move away from him and he can no longer attack me, that he change his image, instead of the one he used to attack me. I would greatly appreciate the help! :D.
RcCookie RcCookie

2022/5/23

#
To determine if something moves away from you, you need to calculate the distance between you and that object (pythagoras) and then compare it to a value computed in the previous frame. If the new value is smaller, you are living towards that object, if it’s greater, away from it. If it is identical, you didn’t move (relative to each other). Finally save the computed value as the last computed value for the next frame
ELquenosabena ELquenosabena

2022/5/23

#
ok, but, could you send me a code, as an example, if you can
You need to login to post a reply.