Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help,
read this.
-
OnACoffeeBreak
- Prole
- Posts: 28
- Joined: Tue Apr 11, 2017 11:19 am
Post
by OnACoffeeBreak » Tue Apr 11, 2017 11:33 am
Without checking the boundaries of a window, an image/sprite will gradually disappear beyond the edge of the window as the player/enemy moves out of bounds. Is it possible to keep this behavior, but have the part of the image that is beyond the window boundary appear along the opposite boundary? In other words, an image moving to the right out of the window will gradually disappear into the right side of the window and at the same time gradually reappear on the left side.
Code: Select all
[ .o0* ]
[ .o0*]
[* .o0]
[0* .o]
[o0* .]
[ .o0* ]
I know this is possible to do with shapes drawn with Love, but I haven't been able to figure out how to do it with an image.
Thanks!
-
Jasoco
- Inner party member
- Posts: 3655
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
-
Contact:
Post
by Jasoco » Tue Apr 11, 2017 1:10 pm
You'll have to draw the image twice. Once at each edge.
-
OnACoffeeBreak
- Prole
- Posts: 28
- Joined: Tue Apr 11, 2017 11:19 am
Post
by OnACoffeeBreak » Tue Apr 11, 2017 1:48 pm
Ha! Thanks! I'm grinning IRL because that is such an obvious solution. This foray into game making has so far been full of these little nuggets and little Eureka moments. It reminds me why I've gotten into programming to begin with.
Appreciate your help!
-
OnACoffeeBreak
- Prole
- Posts: 28
- Joined: Tue Apr 11, 2017 11:19 am
Post
by OnACoffeeBreak » Tue Apr 11, 2017 10:29 pm
So, on the surface this seemed simple. Handling crossing of borders when the image is only crossing a single edge is easy enough, but handing crossing at corners is more involved. I'll have to think on this overnight. Thanks!
-
MasterLee
- Party member
- Posts: 141
- Joined: Tue Mar 07, 2017 4:03 pm
-
Contact:
Post
by MasterLee » Wed Apr 12, 2017 4:53 am
Crossing the borders would need to draw the sprite four times
-
zorg
- Party member
- Posts: 3055
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
-
Contact:
Post
by zorg » Wed Apr 12, 2017 6:44 am
MasterLee wrote: ↑Wed Apr 12, 2017 4:53 am
Crossing the borders would need to draw the sprite four times
No it wouldn't; why would it?
Also, just note how far on both axes is the image beyond the edge in one place, and just use those values subtracted from the image's dimensions in the other place.
Me and my stuff
True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
-
MasterLee
- Party member
- Posts: 141
- Joined: Tue Mar 07, 2017 4:03 pm
-
Contact:
Post
by MasterLee » Wed Apr 12, 2017 10:07 am
I mean crossing the borders, not the border. But i had to state it clearer crossing both borders.
-
Lucyy
- Prole
- Posts: 42
- Joined: Thu Oct 15, 2015 6:57 am
-
Contact:
Post
by Lucyy » Wed Apr 12, 2017 11:33 am
MasterLee wrote: ↑Wed Apr 12, 2017 10:07 am
I mean crossing the borders, not the border. But i had to state it clearer crossing both borders.
Even if you're crossing multiple borders you'd only need to draw your image twice
-
zorg
- Party member
- Posts: 3055
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
-
Contact:
Post
by zorg » Wed Apr 12, 2017 11:34 am
MasterLee wrote: ↑Wed Apr 12, 2017 10:07 am
I mean crossing the borders, not the border. But i had to state it clearer crossing both borders.
Okay, i see what you mean, yeah, worst case, one needs 4 sprites.
Lucyy wrote: ↑Wed Apr 12, 2017 11:33 am
Even if you're crossing multiple borders you'd only need to draw your image twice
At first i thought this too, but i was wrong after i drew it in mspaint; a square (the sprite image) can occupy all 4 corners simultaneously when wrapped around one of them, so that means 4 sprites.
Me and my stuff
True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
-
Lucyy
- Prole
- Posts: 42
- Joined: Thu Oct 15, 2015 6:57 am
-
Contact:
Post
by Lucyy » Wed Apr 12, 2017 11:41 am
zorg wrote: ↑Wed Apr 12, 2017 11:34 am
At first i thought this too, but i was wrong after i drew it in mspaint; a square (the sprite image) can occupy all 4 corners simultaneously when wrapped around one of them, so that means 4 sprites.
Oh, I see what you mean. I guess it depends on how you wrap the image I suppose.
I assumed that the corners would wrap too, like if your image leaves the top side of the screen it's come out at the bottom and if it goes out on the left it'll appear on the right that would mean that crossing both the top and left side it would appear at the bottom right side. And that would only require you to draw 2 images.
Users browsing this forum: Google [Bot] and 29 guests