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.

P#61519 2019-02-05 03:15 ( Edited 2019-02-05 03:16)

:: Jusiv

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.)

P#61520 2019-02-05 04:15 ( Edited 2019-02-05 04:24)

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

P#61521 2019-02-05 04:21
:: Jusiv

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

P#61522 2019-02-05 04:24

How do I load the flag data then?

P#61523 2019-02-05 04:25
:: Jusiv

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.

P#61524 2019-02-05 04:31 ( Edited 2019-02-05 04:35)

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

P#61525 2019-02-05 04:34

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:
Generated 2019-07-16 01:00 | 0.028s | 2097k | Q:24