Compare commits

..

4 Commits

Author SHA1 Message Date
Caspar eba1e4567e Merge remote-tracking branch 'origin/main'
# Conflicts:
#	SMIMS-Game/MyWorld.class
#	SMIMS-Game/MyWorld.java
#	SMIMS-Game/Player.class
#	SMIMS-Game/Player.java
#	SMIMS-Game/project.greenfoot
2026-09-16 17:21:25 +02:00
Caspar a0de2fb58d Startplattform (nicht in MyWorld) 2026-09-16 17:16:52 +02:00
Caspar bfada2dbc2 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	SMIMS-Game/project.greenfoot
2026-09-16 12:20:46 +02:00
Caspar 22d42273c1 MovingPlattformsUpdate 2026-09-16 12:20:29 +02:00
14 changed files with 146 additions and 8 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ public class BreakingPlattform extends Plattform
{ {
IsBreaking= true; IsBreaking= true;
//Greenfoot.playSound("...") //Greenfoot.playSound("...")
this.setImage("BreakingPlattform2.png"); //untested this.setImage("BreakingPlattform2.png");
} }
if(IsBreaking) if(IsBreaking)
Binary file not shown.
+11
View File
@@ -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
+37
View File
@@ -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.
+4 -3
View File
@@ -9,7 +9,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class MovingPlattform extends Plattform public class MovingPlattform extends Plattform
{ {
int speed; int speed;
int temp=0;
public MovingPlattform(int pSpeed) public MovingPlattform(int pSpeed)
{ {
speed= pSpeed; speed= pSpeed;
@@ -42,10 +42,11 @@ public class MovingPlattform extends Plattform
{ {
if(this.PlayerOnPlattform()) 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) if(DerSpieler!=null)
{ {
DerSpieler.setLocation(DerSpieler.getX()+speed, DerSpieler.getY()); DerSpieler.setLocation(DerSpieler.getX()+speed*3, DerSpieler.getY());
} }
} }
} }
+15
View File
@@ -124,6 +124,11 @@ public class Player extends Actor
public void checkHealth(){ public void checkHealth(){
if (health <= 0){ if (health <= 0){
Greenfoot.setWorld(new GameOverWorld()); Greenfoot.setWorld(new GameOverWorld());
return true;
}
else
{
return false;
} }
} }
@@ -147,6 +152,16 @@ public class Player extends Actor
if (health < MAX_HEALTH){ if (health < MAX_HEALTH){
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.
+15
View File
@@ -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
+59
View File
@@ -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