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
This commit is contained in:
2026-09-16 17:21:25 +02:00
31 changed files with 389 additions and 123 deletions
+24 -7
View File
@@ -8,12 +8,15 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
*/
public class Player extends Actor
{
int MAX_HEALTH = 3;
int health = MAX_HEALTH;
int jumpBoostDuration = -1;
int jumpBoostStrength = 5;
boolean projectileReady = false;
int projectileTimer;
private int speed = 6;
private int currentJumpStrength;
private int defaultJumpStrength = 15;
@@ -30,6 +33,7 @@ public class Player extends Actor
fall();
handlePowerUps();
shootProjectile();
checkHealth();
//Check ob der Spieler am unteren Fensterrand ist
if (getY()+1 >= getWorld().getHeight()){
@@ -89,8 +93,8 @@ public class Player extends Actor
}
}
onGround = landed;
}
}
public void shootProjectile(){
projectileTimer++;
MouseInfo mouse = Greenfoot.getMouseInfo();
@@ -106,10 +110,19 @@ public class Player extends Actor
}
}
public boolean collision(){
public void collision(){
if (getIntersectingObjects(Projectile.class).size()>0
|| getIntersectingObjects(Enemy.class).size()>0)
{
health--;
getWorld().removeObjects(getIntersectingObjects(Projectile.class));
getWorld().removeObjects(getIntersectingObjects(Enemy.class));
}
}
public void checkHealth(){
if (health <= 0){
Greenfoot.setWorld(new GameOverWorld());
return true;
}
@@ -118,7 +131,7 @@ public class Player extends Actor
return false;
}
}
public void handlePowerUps(){
if (jumpBoostDuration >= 0){
jumpBoostDuration -= 1;
@@ -126,7 +139,7 @@ public class Player extends Actor
currentJumpStrength = defaultJumpStrength;
}
}
public void reveivePowerUp(int duration, String type){
switch(type){
case "dummy":
@@ -135,6 +148,10 @@ public class Player extends Actor
currentJumpStrength = defaultJumpStrength;
currentJumpStrength += jumpBoostStrength;
jumpBoostDuration = duration;
case "Heal":
if (health < MAX_HEALTH){
health++;
}
case "GroundPower":
World theWorld= this.getWorld();
if(!theWorld.getObjects(TemporaryGround.class).isEmpty())