- Start World to Game World

This commit is contained in:
Max
2026-09-15 19:35:25 +02:00
parent cce1abcc81
commit 60d21d5f68
7 changed files with 30 additions and 32 deletions
+15 -1
View File
@@ -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"));
}
}
}