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)

:: sleepyninja

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)

[Please log in to post a comment]