diff --git a/res/images/items/item3.png b/res/images/items/item3.png index 9c1c635..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/GameFrame.java b/src/de/teamteamteam/spacescooter/GameFrame.java index b2b16d6..55a3d49 100644 --- a/src/de/teamteamteam/spacescooter/GameFrame.java +++ b/src/de/teamteamteam/spacescooter/GameFrame.java @@ -156,9 +156,10 @@ public class GameFrame extends JFrame { /** * Apply rendering hints to the given Graphics2D. + * KEY_ANTIALIASING is very expensive and doesn't do much more over KEY_TEXT_ANTIALIASING */ private void applyRenderingHints(Graphics2D bufferedGraphics) { - bufferedGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + //bufferedGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); bufferedGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } 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/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); } } diff --git a/src/de/teamteamteam/spacescooter/thread/TimedThread.java b/src/de/teamteamteam/spacescooter/thread/TimedThread.java index e2bd386..cbb4c15 100644 --- a/src/de/teamteamteam/spacescooter/thread/TimedThread.java +++ b/src/de/teamteamteam/spacescooter/thread/TimedThread.java @@ -18,6 +18,11 @@ public abstract class TimedThread extends Thread { */ private long workTime; + /** + * This is a quick hack :) + */ + private long runloops; + /** * This method sets the actual working interval based on hz. * @@ -32,6 +37,7 @@ public abstract class TimedThread extends Thread { */ public final void run() { while (true) { + this.runloops++; long workStart = System.nanoTime(); // do the actual work this.work(); @@ -41,8 +47,9 @@ public abstract class TimedThread extends Thread { long timeToWait = this.workInterval - workTime; //in case we are already running late, just print a warning and carry on! - if(timeToWait < 0) { + if(timeToWait < 0 && this.runloops > 50) { // runloops for filtering out game start delays System.err.println("[" + this.getName() + "] workTime exceeds workInterval!:" + this.workTime + " > " + this.workInterval); + runloops = 100; // overflow protect continue; } long msToWait = timeToWait / 1000000;