Gegner werden jetzt in MyWorld gespawned

This commit is contained in:
2026-09-16 17:49:43 +02:00
parent fe11e83e78
commit a39e816038
6 changed files with 146 additions and 110 deletions
+12
View File
@@ -13,6 +13,7 @@ public class MyWorld extends World
//kann später noch beliebig angepasst werden
int targetTimer = 1000;
int time = 0;
int enemyTimer;
int score = 0;
/**
* Constructor for objects of class MyWorld.
@@ -73,6 +74,7 @@ public class MyWorld extends World
score1.setImage("Score2.png");
showScore();
projectile();
spawnEnemies();
targetingProjectile();
if(PlattformCountdown==0) //Damit in regelmäßigen Abständen auf jeden Fall eine Plattform auftaucht
{
@@ -103,6 +105,16 @@ public class MyWorld extends World
}
public void spawnEnemies(){
enemyTimer++;
if (enemyTimer == 420){
Enemy enemy = new Enemy(Greenfoot.getRandomNumber(getWidth()), Greenfoot.getRandomNumber(getHeight()/2));
addObject(enemy, Greenfoot.getRandomNumber(300)+50,0);
enemyTimer = 0;
}
}
public void projectile(){
if(timer == 0){
Projectile projectile = new Projectile();