Updated Items and added the first advanced Item-Icons
This commit is contained in:
parent
f75a93b5cf
commit
4e3964c31c
Binary file not shown.
Before Width: | Height: | Size: 370 B After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 310 B After Width: | Height: | Size: 1.4 KiB |
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,6 +13,6 @@ public class TestItem3 extends Item {
|
|||
|
||||
@Override
|
||||
public void itemCollected(Player player) {
|
||||
player.setShootDamage(player.getShootDamage()+5);
|
||||
player.increaseHealthPoints(15);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue