Log In  


Hi,

Is there a way to make bitwise operations in pico8?
Otherwise, I don't understand how btnwe are supposed to use the bitfields returned by the functions btn() and fget(n).

Shouldn't we be able to do something like :

flag2_set = fget(tile) & 2

I know fget(tile, 2) would work, but I don't see how to use the bitfield. Am I missing something obvious?



The bitwise operations are buried in the math section of the manual:

Bitwise operations
band x y
bor x y
bxor x y
bnot x
shl x y
shr x y

so it would be something like

flag2_set = band(fget(tile), 2)

thanks a lot sleepyninja, I feel quite dumb! I could have sworn I read the manual back to front...



[Please log in to post a comment]