Log In  

I'm working on a platformer game. I'm having an issue with enemy AI.
I want that the enemy will turn the opposite way once it reaches a cliff, much like a collision with a wall.
I want to make a collision check that will check if the floor of the tile after the enemy doesn't have any flags.
How do I do that if 0 means the first flag?

P#103187 2021-12-20 17:10 ( Edited 2021-12-20 17:10)

1

fget(s) will return a single value representing all the flags of sprite s

No flag set will return value zero

Bit index 0 is the first flag, which is value 1
Bit index 1 is the second flag, which is value 2
3rd flag is value 4 etc.

So, for example, first and 3rd flag set would have value 5.

P#103199 2021-12-20 18:34

Thanks!
Well I guess there's something wrong with my code

P#103263 2021-12-21 18:34

OK I solved my problem
I tried to find a tile with no flags with

 if fget(mget(enemy.x/8+17/8,enemy.y/8+10/8),0)

What fixed it was

 if fget(mget(enemy.x/8+17/8,enemy.y/8+10/8))==0
P#103269 2021-12-21 19:09

yes there are two ways to call fget: https://www.lexaloffle.com/dl/docs/pico-8_manual.html#FGET

either you’re asking if flag 0 is set: fget(mapx,mapy,0) → true/false
or you request all flags and check bits: fget(mapx,mapy) → check if bit 0x1 is set

P#103287 2021-12-21 21:41

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 06:47:15 | 0.006s | Q:17