Objects crossing screen boundaries

I working on my an asteroids game and I'm trying to make where objects that leave the right side of the screen appear on the left and so on.

My boundaries go from -200 to 200 in the x and y position.

1
2
3
4
5
6
7
8
  void Point::setY(float value)
{
   _y = value;
   if (y > 230)
       y = -200;
   if (y < -230)
       y = 200;
}


When an object crosses the boundaries, it gets all distorted for a second, then it successfully crosses. Any ideas on how to fix this problem?

THanks
Hi,
What is the main purpose of your second _y in your game?
Set the x and y position if the value is within range.

That function is only a setter. It sets the value of my private x and y. In my constructor I set them to a beginning value of x and y to 0.0 and 0.0.
what exactly do you mean by "distorted"? maybe its only a graphical problem.
try to make the boundaries smaller, that the graphic never actually touches the bounds.
does the distortion still occur?
So here is the link of what happens graphically.

https://www.dropbox.com/s/36i8f64uda8ltfq/Asteroids.png?dl=0

When it starts, everything is normal, but when attempting to cross the screen unto the other side, my objects get distorted for a second, but then they come back to normal.
ah, it seems like the vertices of each asteroid cross the screen one by one.
you need one coordinate for one asteroid, and relative to that local points. then you only need to check if the asteroid center crosses the boundaries, then the local points all reset there position to other side at a stroke.
Topic archived. No new replies allowed.