Bit math can pack some of the checks you've been doing into far fewer tokens and save cycles along the way. The result is a horrific atrocity that the eyes of mortals were never meant to comprehend, but that's the entire point of Pico-8 anyway.
Bit math can pack some of the checks you've been doing into far fewer tokens _and_ save cycles along the way. The result is a horrific atrocity that the eyes of mortals were never meant to comprehend, but that's the entire point of Pico-8 anyway.
integers in the range [0, 15] fit entirely in the bit mask 0x000F. integers out of that range will have at least one bit 0x0010 or higher, or will have the sign bit 0x8000 set. so to find out if one of two numbers is out of range [0, 15], we can check the bit mask of their bitwise or.
this saves tokens and cycles. it is also completely illegible. very in the spirit of Pico-8, I love it.
don't bother exploding crates into four bools, and then comparing them all individually to a bunch of conditions. absurd bit manipulation bullshit saves cycles and tokens. leaving a crate's movement rule represented as four bits means we can exploit our previous calculation of dx1 and dy1, which must each either be 0x0001 or 0x8FFF, and violently hammer them down to align with this bit-packed representation, giving this glorious little atrocity.
I promise this is mathematically equivalent-ish to the original. (0.2 and its multiples are nonterminating decimals in base 2, so there's a little jank when the negative shift right is a shift left.)
kistaro
marked the pull request as ready for review 2022-12-23 08:34:12 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Bit math can pack some of the checks you've been doing into far fewer tokens and save cycles along the way. The result is a horrific atrocity that the eyes of mortals were never meant to comprehend, but that's the entire point of Pico-8 anyway.