Log In  

Cart #qinling_panda_test-0 | 2023-09-07 | Code ▽ | Embed ▽ | No License

Hey! I've been at this for a few hours now but I'm stumped

How do I implement it so that as I reach the edge of the map it endlessly loops back around? I'm trying to do this with a parallax effect on 3 (or maybe eventually 4) layers but I keep ending up walking into blank space

from launch, the easiest way to see this is to just try to walk backwards

only one of the layers is fully drawn but It's not looping correctly at all. some things are commented out as I was debugging but as of rn I'm lost

thanks in advance for any help

P#134031 2023-09-07 18:56 ( Edited 2023-09-07 19:03)

There's a number of ways to do this, but the main thing is that if you have a portion of the screen that's blank, it's because you're not drawing anything there. Given that your character is able to move in both direction, I think the easiest way is to check the position of each layer and draw the layer twice if it one of the edges would be showing.

This would also be made easier by fixing the part of your code that resets the map scrolling. Going to -127 before setting x to 0 means you have 127 map tiles worth of empty space before it resets.

for example, this line:

if mapx <-127 then mapx=0 end

should instead be this:

if mapx < 0 then mapx+=127 end

and then the same in the opposite direction too.
(using += preserves the continuity of the scrolling better)

then in the drawing code, this:

map(mapx, 0)

could be extended like this:

if mapx > 111 then map(mapx-127,0) end
map(mapx, 0)
P#134043 2023-09-08 05:57

[Please log in to post a comment]