--become a king
--chess fan game
function _init()
--poke(0x5f2c,3)
menu=0
ment=1
--title
b=-36
bt=0
--lives
ml=5
l=6
--player
px=14*8
py=11*8
--camera
cx=px-28
cy=py-28
--cursor
mx=px
my=py
--camera move
cvx=0
cvy=0
--pieces
sn=1
sm=6
turns={{
{x=-8,y=0},
{x=8,y=0},
{x=0,y=-8},
{x=0,y=8}
},
{
{x=-16,y=-8},
{x=-16,y=8},
{x=16,y=-8},
{x=16,y=8},
{x=-8,y=-16},
{x=-8,y=16},
{x=8,y=-16},
{x=8,y=16},
},
{
{x=-24,y=-24},
{x=-16,y=-16},
{x=-8,y=-8},
{x=-24,y=24},
{x=-16,y=16},
{x=-8,y=8},
{x=24,y=-24},
{x=16,y=-16},
{x=8,y=-8},
{x=24,y=24},
{x=16,y=16},
{x=8,y=8},
},
{
{x=0,y=-24},
{x=0,y=-16},
{x=0,y=-8},
{x=-24,y=0},
{x=-16,y=0},
{x=-8,y=0},
{x=0,y=24},
{x=0,y=16},
{x=0,y=8},
{x=24,y=0},
{x=16,y=0},
{x=8,y=0},
},
{
{x=-24,y=-24},
{x=-16,y=-16},
{x=-8,y=-8},
{x=-24,y=24},
{x=-16,y=16},
{x=-8,y=8},
{x=24,y=-24},
{x=16,y=-16},
{x=8,y=-8},
{x=24,y=24},
{x=16,y=16},
{x=8,y=8},
{x=0,y=-24},
{x=0,y=-16},
{x=0,y=-8},
{x=-24,y=0},
{x=-16,y=0},
{x=-8,y=0},
{x=0,y=24},
{x=0,y=16},
{x=0,y=8},
{x=24,y=0},
{x=16,y=0},
{x=8,y=0},
},
{
{x=-8,y=-8},
{x=-8,y=0},
{x=-8,y=8},
{x=8,y=-8},
{x=8,y=0},
{x=8,y=8},
{x=0,y=8},
{x=0,y=-8},
}
}
enms={}
for i=0,128 do
local ex=flr(rnd(64))*8
local ey=flr(rnd(64))*8
if fget(mget(ex/8,ey/8),0) then
add(enms,{rnd(11)+1,ex,ey-8})
end
end
music(0)
end
function _update60()
b+=(bt-b)/10
cx+=flr(cvx)
cy+=flr(cvy)
cvx=((px-28)-cx)/5
cvy=((py-28)-cy)/5
if menu==0 then
bt=0
if (btnp(🅾️)) menu=1
elseif menu==1 then
if (btnp(⬅️)) mx-=8
if (btnp(➡️)) mx+=8
if (btnp(⬆️)) my-=8
if (btnp(⬇️)) my+=8
mx=mid(px-24,mx,px+24)
my=mid(py-24,my,py+24)
if (btnp(❎)) menu=2
bt=-46
for t in all(turns[sn]) do
if (btnp(🅾️)) then
if mx==t.x+px and my==t.y+py and fget(mget((t.x+px)/8,(t.y+py)/8),0) then
px=mx
py=my
end
end
end
elseif menu==2 then
if (btnp(🅾️)) menu=1
if (btnp(➡️)) ment+=1
if (btnp(⬅️)) ment-=1
if ment==2 then
if (btnp(⬇️)) sn+=1
if (btnp(⬆️)) sn-=1
sn=mid(1,sn,sm)
end
ment=mid(1,ment,2)
end
camera(cx,cy)
end
function _draw()
cls(12)
map()
if menu==1 then
spr(63,mx,my)
for t in all(turns[sn]) do
if fget(mget((t.x+px)/8,(t.y+py)/8),0) then
spr(16,t.x+px,t.y+py)
end
end
for i=0,ml-1 do
spr(36,i*3+cx,0+cy)
if (i>l-1)spr(37,i*3+cx,0+cy)
end
for e in all(enms) do
spr(e[1]+1,e[2],e[3],1,2)
end
spr(sn,px,py-8,1,2)
spr(80,cx+12,cy+b,6,3)
spr(118,cx+40,cy+b+22,3,1)
elseif menu==0 then
print("press 🅾️",cx+16,cy+51,5)
print("press 🅾️",cx+15,cy+50,6)
spr(sn,px,py-8,1,2)
spr(80,cx+12,cy+b,6,3)
spr(118,cx+40,cy+b+22,3,1)
elseif menu==2 then
cls(12)
if ment==1 then
print("⬅️ map ➡️",cx+14,cy+1,6)
for x=0,128 do
for y=0,64 do
if fget(mget(x,y),0) then
pset(x+cx-px/8+30,y+cy-py/8+30,11)
pset(x+cx-px/8+30,y+cy-py/8+31,4)
end
end
end
pset(cx+30,cy+30,8)
elseif ment==2 then
for x=0,5 do
spr(39+x,x*9+6+cx,18+cy+x*2)
end
print("⬅️ figures ➡️",cx+6,cy+1,6)
rect(sn*9+cx-4,15+cy+sn*2,sn*9+cx+5,24+cy+sn*2,8)
end
end
print("beta version",cx,cy+59,13)
end