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

2013/3/29

moving and turning objects

5
6
7
8
9
danpost danpost

2013/3/31

#
I am running into problems trying to keep the power-ups straight. If they were named better, I probably would not have such a hard time. I took an earlier version (before you added the extra power-ups) and worked it down to 7 subclasses of Actor (no subbing of them) and the one world class, doing the same as what you had wanted at that point. The Actor subclasses were: Counter, Crab, Lobster, Worm, Dominator, WormPower and DominatorPower.
danpost danpost

2013/3/31

#
That same line needs to be added as the first line in the 'wormPowerUp' method in the Worm class, also. Then, in the Crab class, replace your 'ifCanSeeDP2' method with the following:
public void ifCanSeeDP2()
{
    if (canSee(DominatorPower2.class))
    {
        eat(DominatorPower2.class);
        getWorld().removeObjects(getWorld().getObjects(DominatorPower2.class));
        timer3 = 200;
    }
    if (!isdp2PoweredUp()) return;
    timer3--;
    if (timer3 == 0) getWorld().removeObject(dpPowerUp);
}
Gingervitis Gingervitis

2013/3/31

#
danpost wrote...
That same line needs to be added as the first line in the 'wormPowerUp' method in the Worm class, also.
Could be a little more specific to which line and where to place it. I don't fully understand which line you are referring to.
danpost danpost

2013/3/31

#
danpost wrote...
Add the following line as the first line in that same method:
if (getWorld().getObjects(Crab.class).isEmpty()) return;
I think that will take care of the current errors.
The previous was for the 'lobsterPowerUp' method in the Dominator class.
danpost wrote...
That same line needs to be added as the first line in the 'wormPowerUp' method in the Worm class, also.
I thought that was specific enough as to where to place it.
Gingervitis Gingervitis

2013/3/31

#
I had already had that line in the method and the power-up is still stays active.....
danpost danpost

2013/3/31

#
Did you change the method that I revised in my last code post?
Gingervitis Gingervitis

2013/3/31

#
I did.
danpost danpost

2013/3/31

#
Then, the powerup should be getting removed when the counter reaches zero. Try copy/pasting the 'ifCanSeeDP2' method code I provided above over your current method with the same name and try it again (there is a change in the bracketing -- not the code in itself).
Gingervitis Gingervitis

2013/3/31

#
I re-copied the code.... it still stays active. Did it stop for you the next time lobsters appeared on screen?
danpost danpost

2013/3/31

#
It stops when the counter reaches zero.
Gingervitis Gingervitis

2013/3/31

#
It doesn't do that for me.....
Gingervitis Gingervitis

2013/3/31

#
I know what the problem is! I just inspected the Crab while the game was running and when I got the power-up, the timer never counts down.
danpost danpost

2013/3/31

#
It cannot be because of the method as it is now!
Gingervitis Gingervitis

2013/3/31

#
I fixed it. The 'timer--' was never be called. Thank you.
Gingervitis Gingervitis

2013/3/31

#
What do you mean?
There are more replies on the next page.
5
6
7
8
9