Merge remote-tracking branch 'origin/main'
# Conflicts: # SMIMS-Game/Player.class # SMIMS-Game/Player.java # SMIMS-Game/project.greenfoot
This commit is contained in:
+20
-10
@@ -10,13 +10,13 @@ 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;
|
||||
@@ -34,7 +34,7 @@ public class Player extends Actor
|
||||
handlePowerUps();
|
||||
shootProjectile();
|
||||
checkHealth();
|
||||
|
||||
|
||||
//Check ob der Spieler am unteren Fensterrand ist
|
||||
if (getY()+1 >= getWorld().getHeight()){
|
||||
Greenfoot.setWorld(new GameOverWorld());
|
||||
@@ -93,8 +93,8 @@ public class Player extends Actor
|
||||
}
|
||||
}
|
||||
onGround = landed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void shootProjectile(){
|
||||
projectileTimer++;
|
||||
MouseInfo mouse = Greenfoot.getMouseInfo();
|
||||
@@ -119,16 +119,16 @@ public class Player extends Actor
|
||||
getWorld().removeObjects(getIntersectingObjects(Projectile.class));
|
||||
getWorld().removeObjects(getIntersectingObjects(Enemy.class));
|
||||
getWorld().removeObjects(getIntersectingObjects(Spike.class));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void checkHealth(){
|
||||
if (health <= 0){
|
||||
Greenfoot.setWorld(new GameOverWorld());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void handlePowerUps(){
|
||||
if (jumpBoostDuration >= 0){
|
||||
jumpBoostDuration -= 1;
|
||||
@@ -136,7 +136,7 @@ public class Player extends Actor
|
||||
currentJumpStrength = defaultJumpStrength;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void reveivePowerUp(int duration, String type){
|
||||
switch(type){
|
||||
case "dummy":
|
||||
@@ -149,6 +149,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user