Godzil (./19) :
Pour le fun:
function get_pattern(mp,x,y)
local cur=get_tile(mp,x,y)
local ret=0
if ((x>1) and (get_tile(mp,x-1,y)~=cur)) ret = bor(ret,8)
if ((x<16) and (get_tile(mp,x+1,y)~=cur)) ret = bor(ret,2)
if ((y>1) and (get_tile(mp,x,y-1)~=cur)) ret = bor(ret,1)
if ((y<16) and (get_tile(mp,x,y+1)~=cur)) ret = bor(ret,4)
if ret==0 then
if ((x>1) and (y>0) and get_tile(mp,x-1,y-1)~=cur) ret = bor(ret,24)
if ((x<16) and (y>0) and get_tile(mp,x+1,y-1)~=cur) ret = bor(ret,17)
if ((x<16) and (y<16) and get_tile(mp,x+1,y+1)~=cur) ret = bor(ret,18)
if ((x>1) and (y<16) and get_tile(mp,x-1,y+1)~=cur) ret = bor(ret,20)
end
return ret
end
là encore, contexte... j'imagine que c'est du code pico8...
Petite réflexion (mais j'imagine que c'est lié au langage) :
y'a pas de typage ? ret est forcément un entier ?