debug lifetime

This commit is contained in:
nora 2020-12-22 18:41:36 +01:00
parent 81855c6a6d
commit c919d1490b
2 changed files with 14 additions and 0 deletions

View file

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