- Start World to Game World
This commit is contained in:
+15
-1
@@ -10,15 +10,19 @@ public class MyWorld extends World
|
||||
{
|
||||
Player1 player1;
|
||||
Player2 player2;
|
||||
int charakterP1;
|
||||
int charakterP2;
|
||||
/**
|
||||
* Constructor for objects of class MyWorld.
|
||||
*
|
||||
*/
|
||||
public MyWorld()
|
||||
public MyWorld(int pCharakterP1, int pCharakterP2)
|
||||
{
|
||||
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
|
||||
super(600, 400, 1);
|
||||
prepare();
|
||||
charakterP1 = pCharakterP1;
|
||||
charakterP2 = pCharakterP2;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,5 +49,15 @@ public class MyWorld extends World
|
||||
}
|
||||
}
|
||||
showText(String.valueOf(player2.leben),300,300);
|
||||
gameEnd();
|
||||
}
|
||||
|
||||
public void gameEnd(){
|
||||
if(player1.leben == 0){
|
||||
Greenfoot.setWorld(new EndWorld("Player Two"));
|
||||
}
|
||||
if(player2.leben == 0){
|
||||
Greenfoot.setWorld(new EndWorld("Player One"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user