1
General / Re: How can I make a background repeat infinitely?
« on: January 18, 2023, 11:16:13 pm »
One idea is, instead of having one background rectangle, you have multiple side-by-side rectangles that extend beyond the bounds of the window/view. Each of these rectangles has your background texture. This assumes your background texture is seamless so that you don't notice the multiple rectangles, but it sounds like you already have that covered.
Then as your character and view move to the right, for example, you can check if the bounds of the view are close to the edge of the furthest right background rectangle. When this happens, you can create another new rectangle even further to the right. You can also delete the furthest left rectangle once it is no longer within the view. When your character moves left you can create a new rectangle to the left as needed, and delete the furthest right rectangle. This gives the illusion of an infinite background when really you're just creating and deleting background rectangles as needed.
Then as your character and view move to the right, for example, you can check if the bounds of the view are close to the edge of the furthest right background rectangle. When this happens, you can create another new rectangle even further to the right. You can also delete the furthest left rectangle once it is no longer within the view. When your character moves left you can create a new rectangle to the left as needed, and delete the furthest right rectangle. This gives the illusion of an infinite background when really you're just creating and deleting background rectangles as needed.