diff --git a/res/images/items/item3.png b/res/images/items/item3.png index 5aaaf65..2d12ab2 100644 Binary files a/res/images/items/item3.png and b/res/images/items/item3.png differ diff --git a/res/images/items/item4.png b/res/images/items/item4.png index fd349ea..2f200a5 100644 Binary files a/res/images/items/item4.png and b/res/images/items/item4.png differ diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index 689594b..a2a1f30 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -125,4 +125,12 @@ public class Player extends ShootingEntity implements KeyboardListener { return (int) this.shieldPercent; } + public void increaseHealthPoints(int inc) { + if (this.getHealthPoints() <= 85) { + this.setHealthPoints(getHealthPercent() + inc); + } else { + this.setHealthPoints(100); + } + } + } diff --git a/src/de/teamteamteam/spacescooter/entity/item/Item.java b/src/de/teamteamteam/spacescooter/entity/item/Item.java index 47a3b04..32177df 100644 --- a/src/de/teamteamteam/spacescooter/entity/item/Item.java +++ b/src/de/teamteamteam/spacescooter/entity/item/Item.java @@ -24,6 +24,12 @@ public abstract class Item extends CollidableEntity { public void collideWith(Collidable entity) { if(entity instanceof Player) { SoundSystem.playSound("sounds/powerup_pickup.wav"); + while(entityIterator.hasNext()) { + Entity e = entityIterator.next(); + if(e instanceof Player){ + itemCollected((Player) e); + } + } this.remove(); } } @@ -34,12 +40,6 @@ public abstract class Item extends CollidableEntity { this.remove(); }; entityIterator.reset(); - while(entityIterator.hasNext()) { - Entity e = entityIterator.next(); - if(e instanceof Player){ - itemCollected((Player) e); - } - } } public abstract void itemCollected(Player player); diff --git a/src/de/teamteamteam/spacescooter/entity/item/TestItem1.java b/src/de/teamteamteam/spacescooter/entity/item/TestItem1.java index cd400b0..1735360 100644 --- a/src/de/teamteamteam/spacescooter/entity/item/TestItem1.java +++ b/src/de/teamteamteam/spacescooter/entity/item/TestItem1.java @@ -6,7 +6,7 @@ public class TestItem1 extends Item { public TestItem1(int x, int y) { super(x, y); - this.setImage("images/items/item.png"); + this.setImage("images/items/item4.png"); } @Override diff --git a/src/de/teamteamteam/spacescooter/entity/item/TestItem3.java b/src/de/teamteamteam/spacescooter/entity/item/TestItem3.java index 8ff86bd..da47b0f 100644 --- a/src/de/teamteamteam/spacescooter/entity/item/TestItem3.java +++ b/src/de/teamteamteam/spacescooter/entity/item/TestItem3.java @@ -13,6 +13,6 @@ public class TestItem3 extends Item { @Override public void itemCollected(Player player) { - player.setShootDamage(player.getShootDamage()+5); + player.increaseHealthPoints(15); } }