how can I make my enemy move on the x axis from position 250 to 444 without stopping, I hope you help me thanks.
this is my code but it just moves to the right that I should do.
public void act()
{
boolean T;
T=moveLeft();
if(T==true){
moveLeft();
}else{
moveRight();
}
if(moveRight()==false){
moveLeft();
}
}
public boolean moveLeft(){
int x,re;
if(getX()<=444 && getX()>=251){
x=2;
setLocation(getX()-x,getY());
return(true);
}
return(false);
}
public boolean moveRight(){
int x,re;
if(getX()>=250 && getX()<=443){
x=6;
setLocation(getX()+x,getY());
return(true);
}
return(false);
}
}