Do I call a (Java)recursive function for a matrix oscillation (object moving back and forth) or rather nested if loops? Currently I've attempted as such:
public void Jump(double Strength, float[] mvpMatrix){
long time = SystemClock.uptimeMillis() % 4000L;
boolean Direction=true;
for(int u=0; u<2;u++){
if (Direction==true){
for (float i=0; i<Strength;i+=0.0001f){
i=0.0001f*((int) time);
Matrix.translateM(mvpMatrix, 0, i, 0.0f, 0.0f);
draw(mvpMatrix);
if (i>Strength)Direction=false;
}
}
if (Direction==false){
for (float i=Strength; i>0;i-=0.0001f){
i=Strength-(0.0001f*((int) time));
Matrix.translateM(mvpMatrix, 0, i, 0.0f, 0.0f);
draw(mvpMatrix);
if(u==2)return;
if(i==0)Direction=true;
}
}
}
}
But something seems to be wrong. The object moves in one direction and that's it. This function is located in the onDrawFrame() method.