0

For a school project, we are asked to use the graphics module SDL2 and I'm trying to learn the basic concepts of it. I can add texts and images, create rectangles and move them, but ,because I have never written the condition to reappear from the other side of the window, the object get lost. So, now I'm trying to figure out a way to write this condition in C ,but I cannot figure it out. What can I do or where should I start?

I tried to make if statement when the coordinate of the upper-lest corner passes the limit. Obviously, it solves half of the problem, the object stays inside the window but also the whole object teleports directly to the 0 or the end.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • You can solve this by calculating how much of the object is offscreen and then either blit or render copy the remaining part of the object on the other side of the screen. This is opposed to rendering the _entire_ object in one draw call. – SafelyFast Apr 26 '23 at 18:21

0 Answers0