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?

P#14496 2015-09-22 16:35 ( Edited 2015-09-22 21:03)

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)
P#14499 2015-09-22 16:54 ( Edited 2015-09-22 20:54)

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

P#14500 2015-09-22 17:03 ( Edited 2015-09-22 21:03)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-18 21:20:53 | 0.005s | Q:12