Merge branch 'master' of github.com:teamteamteam/SpaceScooter
This commit is contained in:
commit
388417ea3e
Binary file not shown.
Before Width: | Height: | Size: 310 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 |
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -13,6 +13,6 @@ public class TestItem3 extends Item {
|
|||
|
||||
@Override
|
||||
public void itemCollected(Player player) {
|
||||
player.setShootDamage(player.getShootDamage()+5);
|
||||
player.increaseHealthPoints(15);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue