Log In  


 map(level*8,0,0,0,8,15,0)
 for i=1,8,1
  do
  map(level*8+8-i,0,56+i*8,0,1,15)
  end

First I want to say Pico-8 is a lot of fun and I was able to get into it quickly despite barely any knowledge of LUA.

So I got the idea to only draw half a level and mirror it to be symmetrical, however collision detection doesn't seem to work on the right side. I can post more if anyone needs more information, but I've included a GIF showing the issue and the code I used to generate the map.



The map() function has nothing to do with collision, it just draws the image. It's basically like a fancy version of spr().

I think the only reason the collision works for the left half is because those room coordinates align to those of the map part being drawn there. You'll need to code collision for the mirrored half separately.

(So basically when you're on the right half, you'll need to check for collision with tiles starting from the right edge of the map section and checking further left along the map the further right your character goes.)


I'm testing for tile flags to do collision detection. Do the flags not get loaded with map()?


Nope, map() is purely a visual effect. The flag checking is done on the actual map data.


How do I load the flag data then?


It looks like you already have a system in place for recognizing flags. What you need to do is, when you're on the right half, re-use that system but with things like (128-x) instead of x and checking for tiles to the right when you were checking to the left before.

Basically, since you're mirroring the map you need to run collision on the same region of map data but in a mirrored manner.

And when loading other levels you'll need to add an offset to the tiles being checked to ensure it's checking collision with the correct region.


OK I get what you mean. Thank you for the help.



[Please log in to post a comment]