Changed moving point code slightly
This commit is contained in:
parent
e0001d0245
commit
14e7752cfb
|
@ -1,36 +0,0 @@
|
|||
package net.machinemuse.general.geometry;
|
||||
|
||||
public class FlyFromMiddlePoint2D extends Point2D {
|
||||
protected long spawnTime;
|
||||
protected float timeTo;
|
||||
|
||||
public FlyFromMiddlePoint2D(float x, float y, float timeTo) {
|
||||
super(x, y);
|
||||
spawnTime = System.currentTimeMillis();
|
||||
this.timeTo = timeTo;
|
||||
}
|
||||
|
||||
public FlyFromMiddlePoint2D(Point2D target, float timeTo) {
|
||||
this(target.x(), target.y(), timeTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float x() {
|
||||
return doRatio(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float y() {
|
||||
return doRatio(y);
|
||||
}
|
||||
|
||||
public float doRatio(float val) {
|
||||
long elapsed = System.currentTimeMillis() - spawnTime;
|
||||
float ratio = elapsed / timeTo;
|
||||
if (ratio > 1.0F) {
|
||||
return val;
|
||||
} else {
|
||||
return val * ratio;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue