Nice game! Very smooth and addictive gameplay. A great remake of the classic puzzle game. I'm not good at this game, I can't get the 1024 block.
Play game
1024 bytes's itch.io pageCompressed Bytes used
1024
Source Code (OPTIONAL)
function o(x,y,c)
l=15
if(c>0)i=1l=5while i&c==0do i=i<<1l+=1end
rectfill(x,y,x+sz,y+sz,l)end
function addr()cs={}for r=1,4do
for c=1,4 do if(g[r][c]==0)add(cs,{r,c})end
end
if #cs>0 then
a=nil
a_t=t()
p=rnd(cs)
lr=false
ad=true
ng=g
ng[p[1]][p[2]]=rnd()<.9 and 2 or 4
end
lo=#cs<=1
for r=1,4do
for c=1,4do
if(r>1and ng[r][c]==ng[r-1][c])or
(r<4and ng[r][c]==ng[r+1][c])or
(c>1and ng[r][c]==ng[r][c-1])or
(c<4and ng[r][c]==ng[r][c+1])then
lo=false
end
end
end
end
::b::k,sc,fm,w,h,wo=1/7,0,29,6,13,false
g={}
for r=1,4 do add(g,{0,0,0,0})end
addr()
ad=false
::_::cls(5)
?"\^w\^t1024 bytes",6,1,13
?sub(" "..tostr(sc),-5),101,6,10
for c=1,4 do
al=nil
if t()-a_t<k then
if(a)al=a[c]
at=(t()-a_t)/k
else
if ng then
g=ng
ng=nil
p=nil
if(not ad)addr()
end
end
fr,to,d=1,4,1
if(re)fr,to,d=to,fr,-d
for r=fr,to,d do
sz=26
s=g[r][c]
x,y=w+(c-1)*fm,h+(r-1)*fm
if lr then
s=g[c][r]
x,y=w+(r-1)*fm,h+(c-1)*fm
end
if(p and r==p[1] and c==p[2])sz=at*26
if al and al[r] and al[r][1]~=al[r][2] then
ns=lr and ng[c][r] or ng[r][c]
if s>0 then
o(x,y,ns)tl=(al[r][1]+at*(al[r][2]-al[r][1]))*fm
if lr then
x=w+tl
else
y=h+tl
end
end
o(x,y,s)
else
if(p)o(x,y,15)
if(s==1024)o(x,y,14)sz=20wo=true
o(x+13-sz/2,y+13-sz/2,s)
end
if s>0 then
ss=tostr(s)
?"\^t"..(s<1024 and "\^w" or "")..ss,x+14-#ss*(s<1024 and 3.5 or 2),y+9,lo and 5 or 0
end
end
end
if wo or lo then
?"\^iā to replay",40,62,0
if(btnp(ā))goto b
else
if ng==nil then
dir=btnp()
lr=dir==1 or dir==2
if lr or dir==4 or dir==8 then
re=dir==8 or dir==2
a={}
ng={}
for r=1,4 do add(ng,{0,0,0,0})end
fr,to,d=1,4,1
if(re)fr,to,d=to,fr,-d
for c=1,4 do
e=fr-d
i=fr
q={}
al={}
for r=1,4 do add(q,lr and g[c][r] or g[r][c])end
for r=fr,to,d do
if q[r]>0 then
if r~=i then
al[r]={r-1,i-1}
ad=false
end
q[i]=q[r]
if((d==1 and e<i and i>fr) or (d==-1 and e>i and i<fr)) and q[i]==q[i-d]then
al[r]={r-1,i-d-1}
q[i-d]*=2
sc+=q[i-d]
q[i]=0
e=i
ad=false
else
i+=d
end
end
if((d==1 and r>=i) or (d==-1 and r<=i))q[r]=0
end
add(a,al)
for r=fr,to,d do
if lr then
ng[c][r]=q[r]
else
ng[r][c]=q[r]
end
end
end
a_t=t()
p=nil
end
end
end
flip()goto _
Leave a comment
Log in with itch.io to leave a comment.