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?
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.
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 |
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
[Please log in to post a comment]