diff --git a/SMIMS-Game/JumpBoostItem.class b/SMIMS-Game/JumpBoostItem.class index 07d901c..b874d3f 100644 Binary files a/SMIMS-Game/JumpBoostItem.class and b/SMIMS-Game/JumpBoostItem.class differ diff --git a/SMIMS-Game/JumpBoostItem.java b/SMIMS-Game/JumpBoostItem.java index b0c1a69..2368462 100644 --- a/SMIMS-Game/JumpBoostItem.java +++ b/SMIMS-Game/JumpBoostItem.java @@ -8,7 +8,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) */ public class JumpBoostItem extends PowerUps { - int duration = 60*30; + int duration = 60*60; public void act() { touchedByPlayer(); diff --git a/SMIMS-Game/Player.class b/SMIMS-Game/Player.class index c3c2627..54dffb6 100644 Binary files a/SMIMS-Game/Player.class and b/SMIMS-Game/Player.class differ diff --git a/SMIMS-Game/Player.ctxt b/SMIMS-Game/Player.ctxt index 5208ed6..5fff3f3 100644 --- a/SMIMS-Game/Player.ctxt +++ b/SMIMS-Game/Player.ctxt @@ -10,9 +10,11 @@ comment3.target=void\ jump() comment4.params= comment4.target=void\ fall() comment5.params= -comment5.target=boolean\ collision() +comment5.target=void\ shootProjectile() comment6.params= -comment6.target=void\ handlePowerUps() -comment7.params=duration\ type -comment7.target=void\ reveivePowerUp(int,\ java.lang.String) -numComments=8 +comment6.target=boolean\ collision() +comment7.params= +comment7.target=void\ handlePowerUps() +comment8.params=duration\ type +comment8.target=void\ reveivePowerUp(int,\ java.lang.String) +numComments=9 diff --git a/SMIMS-Game/Player.java b/SMIMS-Game/Player.java index c0df63c..f84cc14 100644 --- a/SMIMS-Game/Player.java +++ b/SMIMS-Game/Player.java @@ -11,6 +11,8 @@ public class Player extends Actor int jumpBoostDuration = -1; int jumpBoostStrength = 5; + boolean projectileReady = false; + int projectileTimer; private int speed = 6; private int currentJumpStrength; @@ -27,6 +29,7 @@ public class Player extends Actor jump(); fall(); handlePowerUps(); + shootProjectile(); //Check ob der Spieler am unteren Fensterrand ist if (getY()+1 >= getWorld().getHeight()){ @@ -85,6 +88,21 @@ public class Player extends Actor break; } } onGround = landed; } + + public void shootProjectile(){ + projectileTimer++; + MouseInfo mouse = Greenfoot.getMouseInfo(); + if (Greenfoot.mousePressed(null)){ + PlayerProjectile playerProjectile = new PlayerProjectile(); + getWorld().addObject(playerProjectile, getX(), getY()); + playerProjectile.turnTowards(Greenfoot.getMouseInfo().getX(), Greenfoot.getMouseInfo().getY()); + projectileReady = false; + } + if (projectileTimer >= 10){ + projectileReady = true; + projectileTimer = 0; + } + } public boolean collision(){ if (getIntersectingObjects(Projectile.class).size()>0) diff --git a/SMIMS-Game/PlayerProjectile.class b/SMIMS-Game/PlayerProjectile.class new file mode 100644 index 0000000..104b3f9 Binary files /dev/null and b/SMIMS-Game/PlayerProjectile.class differ diff --git a/SMIMS-Game/PlayerProjectile.ctxt b/SMIMS-Game/PlayerProjectile.ctxt new file mode 100644 index 0000000..a107553 --- /dev/null +++ b/SMIMS-Game/PlayerProjectile.ctxt @@ -0,0 +1,9 @@ +#BlueJ class context +comment0.target=PlayerProjectile +comment0.text=\r\n\ Write\ a\ description\ of\ class\ PlayerProjectile\ 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\ PlayerProjectile\ 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=boolean\ isProjectileOnScreen() +numComments=3 diff --git a/SMIMS-Game/PlayerProjectile.java b/SMIMS-Game/PlayerProjectile.java new file mode 100644 index 0000000..4332be1 --- /dev/null +++ b/SMIMS-Game/PlayerProjectile.java @@ -0,0 +1,34 @@ +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) + +/** + * Write a description of class PlayerProjectile here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class PlayerProjectile extends Actor +{ + /** + * Act - do whatever the PlayerProjectile wants to do. This method is called whenever + * the 'Act' or 'Run' button gets pressed in the environment. + */ + public void act() + { + move(7); + if (!isProjectileOnScreen()){ + getWorld().removeObject(this); + } + } + + public boolean isProjectileOnScreen(){ + //Check Y-Value + if (getY() <= 0 || getY() >= getWorld().getHeight()-1){ + return false; + } + //Check X-Value + if (getX() <= 0 || getX() >= getWorld().getHeight()-1){ + return false; + } + return true; + } +} diff --git a/SMIMS-Game/images/beeper.png b/SMIMS-Game/images/beeper.png new file mode 100644 index 0000000..8968e50 Binary files /dev/null and b/SMIMS-Game/images/beeper.png differ