Compare commits
4 Commits
aa8fb9a067
...
eba1e4567e
| Author | SHA1 | Date | |
|---|---|---|---|
| eba1e4567e | |||
| a0de2fb58d | |||
| bfada2dbc2 | |||
| 22d42273c1 |
@@ -25,7 +25,7 @@ public class BreakingPlattform extends Plattform
|
||||
{
|
||||
IsBreaking= true;
|
||||
//Greenfoot.playSound("...")
|
||||
this.setImage("BreakingPlattform2.png"); //untested
|
||||
this.setImage("BreakingPlattform2.png");
|
||||
|
||||
}
|
||||
if(IsBreaking)
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
#BlueJ class context
|
||||
comment0.target=Groundflower
|
||||
comment0.text=\r\n\ Write\ a\ description\ of\ class\ StarPowerUp\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
|
||||
comment1.params=
|
||||
comment1.target=void\ act()
|
||||
comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ StarPowerUp\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
|
||||
comment2.params=
|
||||
comment2.target=void\ collect()
|
||||
comment3.params=
|
||||
comment3.target=void\ bewegeNachUnten()
|
||||
numComments=4
|
||||
@@ -0,0 +1,37 @@
|
||||
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||
|
||||
/**
|
||||
* Write a description of class StarPowerUp here.
|
||||
*
|
||||
* @author (your name)
|
||||
* @version (a version number or a date)
|
||||
*/
|
||||
public class Groundflower extends PowerUps
|
||||
{
|
||||
int duration= 60*8; //15 Sekunden
|
||||
/**
|
||||
* Act - do whatever the StarPowerUp wants to do. This method is called whenever
|
||||
* the 'Act' or 'Run' button gets pressed in the environment.
|
||||
*/
|
||||
public void act()
|
||||
{
|
||||
bewegeNachUnten();
|
||||
this.touchedByPlayer();
|
||||
// Add your action code here.
|
||||
}
|
||||
|
||||
@ Override void collect()
|
||||
{
|
||||
Player player = getIntersectingObjects(Player.class).get(0);
|
||||
player.reveivePowerUp(duration, "GroundPower");
|
||||
}
|
||||
|
||||
public void bewegeNachUnten()
|
||||
{
|
||||
this.setLocation(this.getX(), this.getY()+2);
|
||||
if(this.getY()>=this.getWorld().getHeight())
|
||||
{
|
||||
this.getWorld().removeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -9,7 +9,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||
public class MovingPlattform extends Plattform
|
||||
{
|
||||
int speed;
|
||||
|
||||
int temp=0;
|
||||
public MovingPlattform(int pSpeed)
|
||||
{
|
||||
speed= pSpeed;
|
||||
@@ -42,10 +42,11 @@ public class MovingPlattform extends Plattform
|
||||
{
|
||||
if(this.PlayerOnPlattform())
|
||||
{
|
||||
Actor DerSpieler = this.getOneObjectAtOffset(0, -40, Player.class);
|
||||
World theWorld= this.getWorld();
|
||||
Player DerSpieler = theWorld.getObjects(Player.class).get(0);
|
||||
if(DerSpieler!=null)
|
||||
{
|
||||
DerSpieler.setLocation(DerSpieler.getX()+speed, DerSpieler.getY());
|
||||
DerSpieler.setLocation(DerSpieler.getX()+speed*3, DerSpieler.getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,11 @@ public class Player extends Actor
|
||||
public void checkHealth(){
|
||||
if (health <= 0){
|
||||
Greenfoot.setWorld(new GameOverWorld());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +152,16 @@ public class Player extends Actor
|
||||
if (health < MAX_HEALTH){
|
||||
health++;
|
||||
}
|
||||
case "GroundPower":
|
||||
World theWorld= this.getWorld();
|
||||
if(!theWorld.getObjects(TemporaryGround.class).isEmpty())
|
||||
{
|
||||
theWorld.getObjects(TemporaryGround.class).get(0).RefreshLifeToDuration(duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
theWorld.addObject((new TemporaryGround(duration)), 200, 550);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
#BlueJ class context
|
||||
comment0.target=TemporaryGround
|
||||
comment0.text=\r\n\ Write\ a\ description\ of\ class\ TemporaryGround\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
|
||||
comment1.params=pLebensdauer
|
||||
comment1.target=TemporaryGround(int)
|
||||
comment2.params=
|
||||
comment2.target=void\ act()
|
||||
comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ TemporaryGround\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
|
||||
comment3.params=
|
||||
comment3.target=void\ warning()
|
||||
comment4.params=
|
||||
comment4.target=void\ noMoreWarning()
|
||||
comment5.params=pDuration
|
||||
comment5.target=void\ RefreshLifeToDuration(int)
|
||||
numComments=6
|
||||
@@ -0,0 +1,59 @@
|
||||
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||
|
||||
/**
|
||||
* Write a description of class TemporaryGround here.
|
||||
*
|
||||
* @author (your name)
|
||||
* @version (a version number or a date)
|
||||
*/
|
||||
public class TemporaryGround extends Plattform
|
||||
{
|
||||
private int Lebensdauer;
|
||||
boolean warningHasHappend=false;
|
||||
boolean deWarningHasHappend=true;
|
||||
public TemporaryGround(int pLebensdauer)
|
||||
{
|
||||
Lebensdauer=pLebensdauer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Act - do whatever the TemporaryGround wants to do. This method is called whenever
|
||||
* the 'Act' or 'Run' button gets pressed in the environment.
|
||||
*/
|
||||
public void act()
|
||||
{
|
||||
// Add your action code here.
|
||||
Lebensdauer--;
|
||||
if(Lebensdauer==0)
|
||||
{
|
||||
this.loescheMich();
|
||||
}
|
||||
if(Lebensdauer<60*3 && warningHasHappend==false) //3 Sekunden
|
||||
{
|
||||
this.warning();
|
||||
}
|
||||
if(Lebensdauer>=60*3 && deWarningHasHappend==false)
|
||||
{
|
||||
this.noMoreWarning();
|
||||
}
|
||||
}
|
||||
|
||||
public void warning()
|
||||
{
|
||||
this.setImage("TemporaryIsBreaking.png");
|
||||
warningHasHappend=true;
|
||||
deWarningHasHappend=false;
|
||||
}
|
||||
|
||||
public void noMoreWarning()
|
||||
{
|
||||
this.setImage("TemporaryGround.png");
|
||||
warningHasHappend=false;
|
||||
deWarningHasHappend=true;
|
||||
}
|
||||
|
||||
public void RefreshLifeToDuration(int pDuration)
|
||||
{
|
||||
Lebensdauer=pDuration;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
Reference in New Issue
Block a user