Plattform Verssion 1

This commit is contained in:
2026-09-15 11:53:27 +02:00
parent 903d791b6b
commit d9f0219cf1
18 changed files with 125 additions and 44 deletions
+28 -1
View File
@@ -8,7 +8,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
*/
public class MyWorld extends World
{
int PlattformCountdown=20;
/**
* Constructor for objects of class MyWorld.
*
@@ -19,6 +19,7 @@ public class MyWorld extends World
super(400, 600, 1);
prepare();
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
@@ -28,4 +29,30 @@ public class MyWorld extends World
Player player = new Player();
addObject(player,302,320);
}
public void act()
{
if(PlattformCountdown==0) //Damit in regelmäßigen Abständen auf jeden Fall eine Plattform auftaucht
{
addObject(new Plattform(), Greenfoot.getRandomNumber(400), 5);
PlattformCountdown=100;
}
PlattformCountdown--;
if(Greenfoot.getRandomNumber(100000)>=99800)
{
addObject(new Plattform(), Greenfoot.getRandomNumber(400), 5);
}
if(Greenfoot.getRandomNumber(100000)>=99900)
{
addObject(new MovingPlattform(2), Greenfoot.getRandomNumber(400), 6); //Nach Rechts bewegende Plattform
}
if(Greenfoot.getRandomNumber(100000)>=99900)
{
addObject(new MovingPlattform(-2), Greenfoot.getRandomNumber(400), 6); //Nach Links bewegende Plattform
}
if(Greenfoot.getRandomNumber(100000)>=99750)
{
addObject(new BreakingPlattform(50), Greenfoot.getRandomNumber(400), 6); //Nach Links bewegende Plattform
}
}
}