I'm trying to animate a shot for my game in JavaFX(Scorched earth). I've been told, since I don't work with a gameloop, the best way would be to make a custom transition with an interpolator but after watching the javadocs I can not seem to figure it out. This is the bullet that gets shot
public void shootBullet(int angle, int v0, double wind) throws ArtilleryException {
try {
double speed = v0;
Tank playerTank = GamePresenter.getPlayers()[0].getTank();
xValues.clear();
yValues.clear();
double cornerRadians = Math.toRadians(angle);
double endX = GameView.CANVAS_WIDTH;
for (int x = 0; x < endX - playerTank.getPosX(); x++) {
int y = (int) (-G / 2 / pow((speed * cos(cornerRadians) - wind), 2) * pow((x), 2) + (x) * sin(cornerRadians) / (cos(cornerRadians) - wind / speed) + playerTank.getPosY());
if (x + playerTank.getPosX() + Tank.getWIDTH() < GameView.CANVAS_WIDTH) {
xValues.add(x + playerTank.getPosX() + Tank.getWIDTH());//
yValues.add(-y + (playerTank.getPosY() + playerTank.getPosY()) - Tank.getHEIGHT() / 2);
}
}
} catch (NumberFormatException e) {
throw new ArtilleryException("Couldn't shoot");
}
}
What I'm basically trying to do is to show an image trough an animation over the xValues list and yValues list. Could someone give me some basic guidelines on how to fill in the public void interpolate(double frac) method?