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

2013/3/29

moving and turning objects

4
5
6
7
8
9
Gingervitis Gingervitis

2013/3/30

#
The error message is still there....
Gingervitis Gingervitis

2013/3/30

#
playing it again.... That fixed it... sorta... Now I only get the error message when the lobster class is empty but the power-up works fine.... actually no... once I get the power-up it is still active when the lobsters are gone
Gingervitis Gingervitis

2013/3/30

#
this will be easier to fix if you have the game..... I will publish it... the power-up is DominatorPower2
danpost danpost

2013/3/30

#
It appears you have two different methods doing basically the same thing: 'lookForLobster' and 'lobstersEaten'. Remove the 'lobstersEaten' method and its call in the act method. It would probably be easier to have the lobster powerup code in the Lobster class instead of here in the Dominator class (it certainly makes sense that it should be there). Give me a little time to re-write the Lobster class with the power-up code (and adjust the Dominator class code).
Gingervitis Gingervitis

2013/3/30

#
do you want the source code? I published it.
danpost danpost

2013/3/30

#
Got it.
Gingervitis Gingervitis

2013/3/30

#
again...
danpost danpost

2013/3/30

#
Yeah, again. To start: copy/paste the following for the 'lobsterPowerUp' method in the Dominator class:
public void lobsterPowerUp()
{
    Crab crab = (Crab) getWorld().getObjects(Crab.class).get(0);
    if (getWorld().getObjects(Lobster.class).isEmpty()) return;
    Lobster lobster = (Lobster) getWorld().getObjects(Lobster.class).get(0);
    
    if (crab != null && crab.dp2Powered())  
    {  
        turnTowards(lobster.getX(), lobster.getY());  
        move(3);  
        //if (getWorld().getObjects(Lobster.class).isEmpty()) return;
    }  
}
Use the 'Plain view' link at the top of the code window.
Gingervitis Gingervitis

2013/3/30

#
should this replace the old code or should I keep the old code too?
danpost danpost

2013/3/30

#
This should replace your 'lobsterPowerUp' method in the Dominator class.
Gingervitis Gingervitis

2013/3/30

#
ok
danpost danpost

2013/3/30

#
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.
Gingervitis Gingervitis

2013/3/30

#
I don't think there are any errors but can you make it so that once you get the DominatorPower2 power-up, the dominator will stop going for the lobsters when the timer goes to zero?
danpost danpost

2013/3/30

#
Will work on it. Got some things to do first.
Gingervitis Gingervitis

2013/3/30

#
Okay. That is totally fine. Take your time. I am in no rush.
There are more replies on the next page.
4
5
6
7
8
9