forked from pyrex/chameleonic
replace comparisons with bit math bullshit
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.
This commit is contained in:
parent
10948ce4a5
commit
fe3a68284f
@ -438,7 +438,7 @@ function level:spawn_exit()
|
||||
if (self:_mget(x,y)!=18) return
|
||||
for nx=x-1,x+1 do
|
||||
for ny=y-1,y+1 do
|
||||
if nx<0 or ny<0 or nx>15 or ny>15 then
|
||||
if (nx | ny) & 0xFFF0 ~= 0 then
|
||||
self._wins[_mix(nx,ny)]=true
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user