Save some tokens in horrible, horrible ways. #13

Merged
pyrex merged 6 commits from kistaro/chameleonic:golf into main 2022-12-24 00:08:10 +00:00
Showing only changes of commit 0fe3b1699f - Show all commits

View File

@ -480,16 +480,18 @@ function _mix(mx,my)
return mx..","..my return mx..","..my
end end
-- crate spec:
-- "up" == 1
-- "right" == 2
-- "down" == 4
-- "left" == 8
--
-- +1+
-- 8 2
-- +4+
function level:_get_cratedef(s) function level:_get_cratedef(s)
if (s<64 or s>=80) return nil if (s<64 or s>=80) return
return s & 0x000F
local s2=s-64
return {
up=s2&1!=0,
right=s2&2!=0,
down=s2&4!=0,
left=s2&8!=0
}
end end
function level:get_latch(dx,dy,px,py) function level:get_latch(dx,dy,px,py)
@ -500,12 +502,11 @@ function level:get_latch(dx,dy,px,py)
local dx1,dy1=-sgn0(dx),-sgn0(dy) local dx1,dy1=-sgn0(dx),-sgn0(dy)
if crate then if crate then
if if crate.def & (
(crate.def.up and dy>0) or dy1 >>> 15 |
(crate.def.down and dy<0) or (dy1 & 0x1) << 2 |
(crate.def.left and dx>0) or (dx1 & 0x8000) >>> 12 |
(crate.def.right and dx<0) (dx1 & 0x1) << 1) ~= 0 then
then
return { return {
el="crate", el="crate",
dx=dx1,dy=dy1, dx=dx1,dy=dy1,