Merge remote-tracking branch 'origin/master'

This commit is contained in:
nora 2020-12-24 14:34:57 +01:00
commit fe9be921fa
2 changed files with 14 additions and 0 deletions

View file

@ -9,10 +9,19 @@ import java.awt.*;
* A GameObject used for debugging * A GameObject used for debugging
*/ */
public class DebugPos extends GameObject { public class DebugPos extends GameObject {
private final long lifeTime;
private long spawnTime;
public DebugPos(Vector2D position, Vector2D size) { public DebugPos(Vector2D position, Vector2D size) {
this(position, size, Long.MAX_VALUE);
}
public DebugPos(Vector2D position, Vector2D size, long lifeTime) {
super(position.copy(), size); super(position.copy(), size);
this.velocity = new Vector2D(); this.velocity = new Vector2D();
this.mainColor = Color.GREEN; this.mainColor = Color.GREEN;
this.lifeTime = lifeTime;
} }
@Override @Override
@ -22,5 +31,10 @@ public class DebugPos extends GameObject {
@Override @Override
public void update() { public void update() {
long current = System.currentTimeMillis();
if (current - spawnTime > lifeTime) {
destroy();
}
} }
} }