I want a loop that can count back and forth from 0 to 3. At first it counts up 1 each time and then when it reaches 3, it will count backwards to 0, then back up to 3 and so on. I already have a runnable that makes it count automatically.
Here is the code:
moveInt++;
animateInt++;
if(animateInt==20){
if(!max){
badGuyInt +=1; //count up 1
}
if(max){
badGuyInt -=1; //count back 1
}
animateInt=0;
if(badGuyInt==3){ //When it reaches 3, it will start to count down.
badGuyInt=0;
max = true;
}
if(badGuyInt==0){// When it reaches 0, it counts up.
max = false;
}
}
The way it's written now, it just goes back to 2 when it reaches 3 then back to 3, and back to 2 and so on. I want it to go all the way back to 0 before it starts to count up again.