Fix:My World Plattformen
This commit is contained in:
Binary file not shown.
@@ -7,4 +7,6 @@ comment1.text=\r\n\ Constructor\ for\ objects\ of\ class\ MyWorld.\r\n\ \r\n
|
|||||||
comment2.params=
|
comment2.params=
|
||||||
comment2.target=void\ prepare()
|
comment2.target=void\ prepare()
|
||||||
comment2.text=\r\n\ Prepare\ the\ world\ for\ the\ start\ of\ the\ program.\r\n\ That\ is\:\ create\ the\ initial\ objects\ and\ add\ them\ to\ the\ world.\r\n
|
comment2.text=\r\n\ Prepare\ the\ world\ for\ the\ start\ of\ the\ program.\r\n\ That\ is\:\ create\ the\ initial\ objects\ and\ add\ them\ to\ the\ world.\r\n
|
||||||
numComments=3
|
comment3.params=
|
||||||
|
comment3.target=void\ act()
|
||||||
|
numComments=4
|
||||||
|
|||||||
+27
-1
@@ -8,7 +8,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
|||||||
*/
|
*/
|
||||||
public class MyWorld extends World
|
public class MyWorld extends World
|
||||||
{
|
{
|
||||||
|
int PlattformCountdown;
|
||||||
/**
|
/**
|
||||||
* Constructor for objects of class MyWorld.
|
* Constructor for objects of class MyWorld.
|
||||||
*
|
*
|
||||||
@@ -28,4 +28,30 @@ public class MyWorld extends World
|
|||||||
Player player = new Player();
|
Player player = new Player();
|
||||||
addObject(player,302,320);
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user