This site requires JavaScript, please enable it in your browser!
Greenfoot
Username
Password
Remember Me?
Sign Up, Lost Password
Activity
About
Documentation
Download
Discuss
Scenarios
MuchieBun
wrote ...
2023/5/9
How to code Player chasing an actor but it runs away as much as possible from the player?
MuchieBun
2023/5/9
#
It's like ghost from Pacman. I don't know how to code it, I've found sources but I can't understand it how it works. It's really difficult.
danpost
2023/5/9
#
MuchieBun wrote...
It's like ghost from Pacman. I don't know how to code it, I've found sources but I can't understand it how it works. It's really difficult.
To run away:
turnTowards(player.getX(), player.getY()); turn(180); move(5);
That is one way, at least. The idea of other ways is the same. Determine where (and possibly, how close) the player is, then turn away and move it.
You need to login to post a reply.
X