I have the problem that after a lapse of time some of the asteroids get stuck in the vertex of the world
public class Asteroide extends Actor{
public static final int NO_B = 0;
public void act(){
World g = getWorld();
randomturn();
teleAtEdge();
}
int direction = Greenfoot.getRandomNumber(360);
int tumbleRate = 0;
public void randomturn(){
{
int rotation = getRotation();
setRotation(direction);
move(3);
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);
}
}
}
}