I have the problem that sometimes when an asteroid touches the right edge, it stays stuck on that edge and does not pass to the other edge of the world like the others and it gets stuck on that edge. help please
public class Asteroide extends Actor{
public void act(){
move(5);
World g = getWorld();
randomturn();
teleAtEdge();
}
int direction = Greenfoot.getRandomNumber(360);
int tumbleRate = 0;
public void randomturn(){
{
int rotation = getRotation();
setRotation(direction);
move(5);
setRotation(rotation+tumbleRate);
}
}
public void teleAtEdge(){
if (isAtEdge()){
int w = getWorld().getWidth();
int h = getWorld().getHeight();
int x = getX();
int y = getY();
if (x >= w - 1) {
setLocation(0, y);
}else if ( x <= 1 ) {
setLocation(w,y);
}
if( y <= 1 ) {
setLocation(x,h);
}else if ( y >= h - 1 ) {
setLocation(x,0);
}
}
}
}


