My subclass HUMAN has two subclasses: MAN and WOMAN
First of all if the men get image2 ( the image of an ill man ) they should die. If three men died, the game should stop and the object GameOver which is just an image should appear. The variable is already declared. But it doesn't work.... Even if I pause the game and inspect an object, the variable said 0. The code is written in Men.class
The second problem is that i don't want the game stop after three men died but after three humans died.. this variable has to be counted in the WOMAN.class as well. And then they both have to be counted together... something like that if you know what i mean...
1 2 3 4 5 | if (getImage() == image2) { getWorld().removeObject( this ); peopleDied = peopleDied + 1 ; } |
1 2 3 4 5 6 7 8 | public void gameOver() { if (peopleDied == 3 ) { Greenfoot.stop() getWorld().addObject( new GameOver(), 392 , 296 ); } } |