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

2014/5/28

returning to ghost house

1
2
newprogramming newprogramming

2014/5/28

#
this is a pacman game with a lady bug and i need help to getting the ghost to return itself to the ghost house after it intersects with the lady bug. So far i have done it that it sets the direction toward where the ghost house is i have been using the codes like if isAboveMe(getGhostHealer()) { setDirection(UP); move(); } but it doesnt even move up
danpost danpost

2014/5/28

#
The 'move' method should be given; plus, any pertinent codes stemming from it.
newprogramming newprogramming

2014/5/28

#
what do you mean? the move code is given and what is meant by pertinent codes?
danpost danpost

2014/5/28

#
if isAboveMe(getGhostHealer())
{
    setDirection(UP);
    move();
}
Line 4 calls a method that must be in the class it is being called from. What is its code? (you are not calling the 'move(int)' method supplied by greenfoot.Actor because there is no 'int' parameter. If you are getting an error message, you should have stated so; supplied exactly what it said and where it refers to.
newprogramming newprogramming

2014/5/28

#
no im doing move(3);
danpost danpost

2014/5/28

#
newprogramming wrote...
no im doing move(3);
In the future, please show your actual code (do not abbreviate it). Also, use the 'code' link provided below the 'Post a reply' box to insert your code snippets into your posts. Alright, let us try again (post your code). Also relevant might be the 'isAboveMe' method (if you have one).
newprogramming newprogramming

2014/5/28

#
i cant post my full code because this is an assignment and i will lose marks for plagarism if its online but i do use the isAboveMe method as shown if(isAboveMe(getGhostHealer())) { setDirection(UP); move(3); }
danpost danpost

2014/5/28

#
Well, if your actor is not moving then probably the 'isAboveMe(getGhostHealer())' condition is never returning a 'true' value. Check the logic of that method.
newprogramming newprogramming

2014/5/28

#
no it moves but it doesn't make its way to the ghost healer it just moves around randomly
danpost danpost

2014/5/28

#
Describe in more detail what it is doing (how, where, whatever). Is it acting like it is not dead? You need to supply all the information you can, especially if you cannot supply your code. Otherwise, it will take forever to get it resolved.
newprogramming newprogramming

2014/5/28

#
ok to sum it up the ghosts are programmed to move randomly where the intersections are. When the lady bug eats the mushroom the ghost is eatable and when eaten the ghost must go back to the ghost healer however it moves in the direction but when it reaches the intersection it randomly picking a space to move so i put in isAboveMe, isBelowMe etc. in order to get it to move in the direction of the ghost healer however it stills continues to move randomly
danpost danpost

2014/5/28

#
Sounds like your condition to return is only being used to initiate its return (and not throughout the return) to the healer. You should probably have an instance boolean field for the ghosts named something like 'wasEaten' set to true when eaten and set back to false when arriving at the healer. Use its value to determine whether normal movement or return-to-healer movement should be executed. BTW, the way the ghosts return in Pac-Man(r) is to float over the walls moving directly toward the healer.
newprogramming newprogramming

2014/5/28

#
ok i've tried that and i have made wasEaten=true for the 1 if statement needed to return to healer and the others false however it is still not going there
danpost danpost

2014/5/28

#
It would be pretty much impossible to help without more information, then.
sumrandom sumrandom

2014/5/29

#
do you go uws?
There are more replies on the next page.
1
2