mirror of
https://github.com/Noratrieb/Java2DGame.git
synced 2026-01-14 22:15:01 +01:00
debug lifetime
This commit is contained in:
parent
81855c6a6d
commit
c919d1490b
2 changed files with 14 additions and 0 deletions
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue