自定义场地多页面功能(暂不支持多页复制)
This commit is contained in:
@@ -359,6 +359,11 @@ return{
|
|||||||
copy="Copy",
|
copy="Copy",
|
||||||
paste="Paste",
|
paste="Paste",
|
||||||
clear="Clear",
|
clear="Clear",
|
||||||
|
|
||||||
|
newPage="New Page(N)",
|
||||||
|
delPage="Del Page(M)",
|
||||||
|
prevPage="Prev Page",
|
||||||
|
nextPage="Next Page",
|
||||||
pushLine="Add Line(K)",
|
pushLine="Add Line(K)",
|
||||||
delLine="Del Line(L)",
|
delLine="Del Line(L)",
|
||||||
demo="Don't Show ×",
|
demo="Don't Show ×",
|
||||||
|
|||||||
@@ -363,6 +363,11 @@ return{
|
|||||||
copy="Copier",
|
copy="Copier",
|
||||||
paste="Coller",
|
paste="Coller",
|
||||||
clear="Nettoyer",
|
clear="Nettoyer",
|
||||||
|
|
||||||
|
-- newPage="New Page(N)",
|
||||||
|
-- delPage="Del Page(M)",
|
||||||
|
-- prevPage="Prev Page",
|
||||||
|
-- nextPage="Next Page",
|
||||||
pushLine="Ajouter ligne (K)",
|
pushLine="Ajouter ligne (K)",
|
||||||
delLine="Supprimer ligne (L)",
|
delLine="Supprimer ligne (L)",
|
||||||
demo="Masquer les ×",
|
demo="Masquer les ×",
|
||||||
|
|||||||
@@ -362,6 +362,11 @@ return{
|
|||||||
copy="Copiar",
|
copy="Copiar",
|
||||||
paste="Pegar",
|
paste="Pegar",
|
||||||
clear="Limpiar",
|
clear="Limpiar",
|
||||||
|
|
||||||
|
-- newPage="New Page(N)",
|
||||||
|
-- delPage="Del Page(M)",
|
||||||
|
-- prevPage="Prev Page",
|
||||||
|
-- nextPage="Next Page",
|
||||||
pushLine="Añadir Línea (K)",
|
pushLine="Añadir Línea (K)",
|
||||||
delLine="Borrar Línea (L)",
|
delLine="Borrar Línea (L)",
|
||||||
demo="No Mostrar X",
|
demo="No Mostrar X",
|
||||||
|
|||||||
@@ -313,6 +313,11 @@ return{
|
|||||||
copy="→__",
|
copy="→__",
|
||||||
paste="__→",
|
paste="__→",
|
||||||
clear="XXX",
|
clear="XXX",
|
||||||
|
|
||||||
|
newPage="+[_](N)",
|
||||||
|
delPage="x[_](M)",
|
||||||
|
prevPage="←[_]",
|
||||||
|
nextPage="[_]→",
|
||||||
pushLine="↑↑↑↑↑(K)",
|
pushLine="↑↑↑↑↑(K)",
|
||||||
delLine="==X==(L)",
|
delLine="==X==(L)",
|
||||||
demo="X ×",
|
demo="X ×",
|
||||||
|
|||||||
@@ -361,6 +361,11 @@ return{
|
|||||||
copy="复制",
|
copy="复制",
|
||||||
paste="粘贴",
|
paste="粘贴",
|
||||||
clear="清除",
|
clear="清除",
|
||||||
|
|
||||||
|
newPage="新页面(N)",
|
||||||
|
delPage="删除页面(M)",
|
||||||
|
prevPage="上一页面",
|
||||||
|
nextPage="下一页面",
|
||||||
pushLine="增加一行(K)",
|
pushLine="增加一行(K)",
|
||||||
delLine="消除行(L)",
|
delLine="消除行(L)",
|
||||||
demo="不显示×",
|
demo="不显示×",
|
||||||
|
|||||||
@@ -534,7 +534,11 @@ end
|
|||||||
function copyList(org)
|
function copyList(org)
|
||||||
local L={}
|
local L={}
|
||||||
for i=1,#org do
|
for i=1,#org do
|
||||||
L[i]=org[i]
|
if type(org[i])~="table"then
|
||||||
|
L[i]=org[i]
|
||||||
|
else
|
||||||
|
L[i]=copyList(org[i])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return L
|
return L
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -522,13 +522,18 @@ local Widgets={
|
|||||||
newButton({name="b23", x=1060, y=290,w=75,color="dRed", code=setPen(23)}),--GB4
|
newButton({name="b23", x=1060, y=290,w=75,color="dRed", code=setPen(23)}),--GB4
|
||||||
newButton({name="b24", x=1140, y=290,w=75,color="dGreen", code=setPen(24)}),--GB5
|
newButton({name="b24", x=1140, y=290,w=75,color="dGreen", code=setPen(24)}),--GB5
|
||||||
|
|
||||||
newButton({name="any", x=600, y=400, w=120, color="lGrey", font=40,code=setPen(0)}),
|
newButton({name="any", x=600, y=400,w=120,color="lGrey", font=40,code=setPen(0)}),
|
||||||
newButton({name="space", x=730, y=400, w=120, color="grey", font=65,code=setPen(-1)}),
|
newButton({name="space", x=730, y=400,w=120,color="grey", font=65,code=setPen(-1)}),
|
||||||
newButton({name="copy", x=905, y=400, w=120, color="lRed", font=35,code=pressKey("cC")}),
|
newButton({name="copy", x=905, y=400,w=120,color="lRed", font=35,code=pressKey("cC")}),
|
||||||
newButton({name="paste", x=1035, y=400, w=120, color="lBlue", font=35,code=pressKey("cV")}),
|
newButton({name="paste", x=1035, y=400,w=120,color="lBlue", font=35,code=pressKey("cV")}),
|
||||||
newButton({name="clear", x=1165, y=400, w=120, color="white", font=40,code=pressKey("delete")}),
|
newButton({name="clear", x=1165, y=400,w=120,color="white", font=40,code=pressKey("delete")}),
|
||||||
newButton({name="pushLine", x=1035, y=530, w=120, color="lYellow",font=20,code=pressKey("k")}),
|
|
||||||
newButton({name="delLine", x=1165, y=530, w=120, color="lYellow",font=20,code=pressKey("l")}),
|
newButton({name="newPage", x=680, y=530,w=90,h=90,color="sky",font=15,code=pressKey("n")}),
|
||||||
|
newButton({name="delPage", x=780, y=530,w=90,h=90,color="lRed",font=15,code=pressKey("m")}),
|
||||||
|
newButton({name="prevPage", x=880, y=530,w=90,h=90,color="lGreen",font=15,code=pressKey("sTab"),hide=STPeq("page",1)}),
|
||||||
|
newButton({name="nextPage", x=980, y=530,w=90,h=90,color="lGreen",font=15,code=pressKey("tab"),hide=function()return sceneTemp.page==#FIELD end}),
|
||||||
|
newButton({name="pushLine", x=1080, y=530,w=90,h=90,color="lYellow",font=20,code=pressKey("k")}),
|
||||||
|
newButton({name="delLine", x=1180, y=530,w=90,h=90,color="lYellow",font=20,code=pressKey("l")}),
|
||||||
newSwitch({name="demo", x=755, y=640, disp=STPval("demo"),code=STPrev("demo")}),
|
newSwitch({name="demo", x=755, y=640, disp=STPval("demo"),code=STPrev("demo")}),
|
||||||
|
|
||||||
newButton({name="back", x=1140, y=640, w=170,h=80,font=40,code=BACK}),
|
newButton({name="back", x=1140, y=640, w=170,h=80,font=40,code=BACK}),
|
||||||
|
|||||||
13
main.lua
13
main.lua
@@ -75,7 +75,7 @@ customEnv={
|
|||||||
bg="none",
|
bg="none",
|
||||||
bgm="race"
|
bgm="race"
|
||||||
}
|
}
|
||||||
FIELD={h=20}for i=1,20 do FIELD[i]={0,0,0,0,0,0,0,0,0,0}end--Field for custom game
|
FIELD={}--Field(s) for custom game
|
||||||
BAG={}--Sequence for custom game
|
BAG={}--Sequence for custom game
|
||||||
MISSION={}--Clearing mission for custom game
|
MISSION={}--Clearing mission for custom game
|
||||||
|
|
||||||
@@ -108,14 +108,17 @@ CURMODE=nil--Current mode object
|
|||||||
|
|
||||||
--Load modules
|
--Load modules
|
||||||
require("Zframework")--Load Zframework
|
require("Zframework")--Load Zframework
|
||||||
|
|
||||||
|
require("parts/list")
|
||||||
|
require("parts/default_data")
|
||||||
|
require("parts/gametoolfunc")
|
||||||
|
|
||||||
|
FIELD[1]=newBoard()--Initialize field[1]
|
||||||
|
|
||||||
blocks= require("parts/mino")
|
blocks= require("parts/mino")
|
||||||
AITemplate= require("parts/AITemplate")
|
AITemplate= require("parts/AITemplate")
|
||||||
freeRow= require("parts/freeRow")
|
freeRow= require("parts/freeRow")
|
||||||
|
|
||||||
require("parts/list")
|
|
||||||
require("parts/gametoolfunc")
|
|
||||||
require("parts/default_data")
|
|
||||||
|
|
||||||
TEXTURE=require("parts/texture")
|
TEXTURE=require("parts/texture")
|
||||||
SKIN= require("parts/skin")
|
SKIN= require("parts/skin")
|
||||||
PLY= require("parts/player")
|
PLY= require("parts/player")
|
||||||
|
|||||||
@@ -1,9 +1,53 @@
|
|||||||
local int=math.floor
|
local int=math.floor
|
||||||
|
|
||||||
|
local function notAir(L)
|
||||||
|
for i=1,10 do
|
||||||
|
if L[i]>0 then return true end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function setField(P,page)
|
||||||
|
local F=FIELD[page]
|
||||||
|
local height=0
|
||||||
|
for y=20,1,-1 do
|
||||||
|
if notAir(F[y])then
|
||||||
|
height=y
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local t=P.showTime*3
|
||||||
|
for y=1,height do
|
||||||
|
local solid=notAir(F[y])
|
||||||
|
P.field[y]=freeRow.get(0,solid)
|
||||||
|
P.visTime[y]=freeRow.get(t)
|
||||||
|
if solid then
|
||||||
|
for x=1,10 do
|
||||||
|
P.field[y][x]=F[y][x]
|
||||||
|
end
|
||||||
|
P.garbageBeneath=P.garbageBeneath+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function checkClear(P)
|
||||||
|
if P.garbageBeneath==0 then
|
||||||
|
P.modeData.point=P.modeData.point+1
|
||||||
|
if FIELD[P.modeData.point+1]then
|
||||||
|
P.waiting=26
|
||||||
|
for _=#P.field,1,-1 do
|
||||||
|
freeRow.discard(P.field[_])
|
||||||
|
freeRow.discard(P.visTime[_])
|
||||||
|
P.field[_],P.visTime[_]=nil
|
||||||
|
end
|
||||||
|
setField(P,P.modeData.point+1)
|
||||||
|
sysFX.newShade(.7,.6,.8,.6,P.x+150*P.size,P.y+60*P.size,300*P.size,610*P.size)
|
||||||
|
SFX.play("blip_1")
|
||||||
|
else
|
||||||
|
P:win("finish")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
return{
|
return{
|
||||||
color=color.white,
|
color=color.white,
|
||||||
env={
|
env={},
|
||||||
dropPiece=PLY.check_lineReach,
|
|
||||||
},
|
|
||||||
load=function()
|
load=function()
|
||||||
for k,v in next,customEnv do
|
for k,v in next,customEnv do
|
||||||
modeEnv[k]=v
|
modeEnv[k]=v
|
||||||
@@ -18,6 +62,19 @@ return{
|
|||||||
else
|
else
|
||||||
modeEnv.mission=nil
|
modeEnv.mission=nil
|
||||||
end
|
end
|
||||||
|
local clearmode
|
||||||
|
if FIELD[1]then
|
||||||
|
for y=1,20 do
|
||||||
|
if notAir(FIELD[1][y])then
|
||||||
|
clearmode=true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if clearmode then
|
||||||
|
modeEnv.dropPiece=checkClear
|
||||||
|
else
|
||||||
|
modeEnv.dropPiece=PLY.check_lineReach
|
||||||
|
end
|
||||||
PLY.newPlayer(1,340,15)
|
PLY.newPlayer(1,340,15)
|
||||||
local L=modeEnv.opponent
|
local L=modeEnv.opponent
|
||||||
if L~=0 then
|
if L~=0 then
|
||||||
@@ -28,24 +85,8 @@ return{
|
|||||||
PLY.newAIPlayer(2,965,360,.5,AITemplate("CC",2*L-11,int(L*.5-1.5),modeEnv.hold,4000*L))
|
PLY.newAIPlayer(2,965,360,.5,AITemplate("CC",2*L-11,int(L*.5-1.5),modeEnv.hold,4000*L))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
FIELD.h=20
|
|
||||||
repeat
|
|
||||||
for i=1,10 do
|
|
||||||
if FIELD[FIELD.h][i]>0 then
|
|
||||||
goto L
|
|
||||||
end
|
|
||||||
end
|
|
||||||
FIELD.h=FIELD.h-1
|
|
||||||
until FIELD.h==0
|
|
||||||
::L::
|
|
||||||
for _,P in next,PLAYERS.alive do
|
for _,P in next,PLAYERS.alive do
|
||||||
local t=P.showTime*3
|
setField(P,1)
|
||||||
for y=1,FIELD.h do
|
|
||||||
P.field[y]=freeRow.get(0,true)
|
|
||||||
P.visTime[y]=freeRow.get(t)
|
|
||||||
for x=1,10 do P.field[y][x]=FIELD[y][x]end
|
|
||||||
end
|
|
||||||
P.garbageBeneath=FIELD.h
|
|
||||||
end
|
end
|
||||||
modeEnv.bg=customEnv.bg
|
modeEnv.bg=customEnv.bg
|
||||||
modeEnv.bgm=customEnv.bgm
|
modeEnv.bgm=customEnv.bgm
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
local gc=love.graphics
|
local gc=love.graphics
|
||||||
local int=math.floor
|
local int=math.floor
|
||||||
local function puzzleCheck(P)
|
local function puzzleCheck(P)
|
||||||
|
local F=FIELD[P.modeData.point+1]
|
||||||
for y=1,20 do
|
for y=1,20 do
|
||||||
local L=P.field[y]
|
local L=P.field[y]
|
||||||
for x=1,10 do
|
for x=1,10 do
|
||||||
local a,b=FIELD[y][x],L and L[x]or 0
|
local a,b=F[y][x],L and L[x]or 0
|
||||||
if a~=0 then
|
if a~=0 then
|
||||||
if a==-1 then if b>0 then return end
|
if a==-1 then if b>0 then return end
|
||||||
elseif a<12 then if a~=b then return end
|
elseif a<12 then if a~=b then return end
|
||||||
@@ -13,8 +14,21 @@ local function puzzleCheck(P)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
P.modeData.event=1
|
P.modeData.point=P.modeData.point+1
|
||||||
P:win("finish")
|
if FIELD[P.modeData.point+1]then
|
||||||
|
P.waiting=26
|
||||||
|
for _=#P.field,1,-1 do
|
||||||
|
freeRow.discard(P.field[_])
|
||||||
|
freeRow.discard(P.visTime[_])
|
||||||
|
P.field[_],P.visTime[_]=nil
|
||||||
|
end
|
||||||
|
sysFX.newShade(.7,.3,1,.3,P.x+150*P.size,P.y+60*P.size,300*P.size,610*P.size)
|
||||||
|
SFX.play("reach")
|
||||||
|
P.modeData.event=0
|
||||||
|
else
|
||||||
|
P.modeData.event=1
|
||||||
|
P:win("finish")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return{
|
return{
|
||||||
@@ -47,16 +61,6 @@ return{
|
|||||||
PLY.newAIPlayer(2,965,360,.5,AITemplate("CC",2*L-11,int(L*.5-1.5),modeEnv.hold,4000*L))
|
PLY.newAIPlayer(2,965,360,.5,AITemplate("CC",2*L-11,int(L*.5-1.5),modeEnv.hold,4000*L))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
FIELD.h=20
|
|
||||||
repeat
|
|
||||||
for i=1,10 do
|
|
||||||
if FIELD[FIELD.h][i]~=0 then
|
|
||||||
goto L
|
|
||||||
end
|
|
||||||
end
|
|
||||||
FIELD.h=FIELD.h-1
|
|
||||||
until FIELD.h==0
|
|
||||||
::L::
|
|
||||||
modeEnv.bg=customEnv.bg
|
modeEnv.bg=customEnv.bg
|
||||||
modeEnv.bgm=customEnv.bgm
|
modeEnv.bgm=customEnv.bgm
|
||||||
end,
|
end,
|
||||||
@@ -67,8 +71,9 @@ return{
|
|||||||
mText(drawableText.line,69,360)
|
mText(drawableText.line,69,360)
|
||||||
if P.modeData.event==0 then
|
if P.modeData.event==0 then
|
||||||
local m=puzzleMark
|
local m=puzzleMark
|
||||||
for y=1,FIELD.h do for x=1,10 do
|
local F=FIELD[P.modeData.point+1]
|
||||||
local T=FIELD[y][x]
|
for y=1,20 do for x=1,10 do
|
||||||
|
local T=F[y][x]
|
||||||
if T~=0 then
|
if T~=0 then
|
||||||
gc.draw(m[T],150+30*x-30+dx,70+600-30*y+dy)
|
gc.draw(m[T],150+30*x-30+dx,70+600-30*y+dy)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -140,13 +140,23 @@ function pasteSequence(str)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function copyBoard()
|
function newBoard(f)
|
||||||
|
if f then
|
||||||
|
return copyList(f)
|
||||||
|
else
|
||||||
|
local F={}
|
||||||
|
for i=1,20 do F[i]={0,0,0,0,0,0,0,0,0,0}end
|
||||||
|
return F
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function copyBoard(page)
|
||||||
|
local F=FIELD[page or 1]
|
||||||
local str=""
|
local str=""
|
||||||
local H=0
|
local H=0
|
||||||
|
|
||||||
for y=20,1,-1 do
|
for y=20,1,-1 do
|
||||||
for x=1,10 do
|
for x=1,10 do
|
||||||
if FIELD[y][x]~=0 then
|
if F[y][x]~=0 then
|
||||||
H=y
|
H=y
|
||||||
goto topFound
|
goto topFound
|
||||||
end
|
end
|
||||||
@@ -157,7 +167,7 @@ function copyBoard()
|
|||||||
--Encode field
|
--Encode field
|
||||||
for y=1,H do
|
for y=1,H do
|
||||||
local S=""
|
local S=""
|
||||||
local L=FIELD[y]
|
local L=F[y]
|
||||||
for x=1,10 do
|
for x=1,10 do
|
||||||
S=S..char(L[x]+1)
|
S=S..char(L[x]+1)
|
||||||
end
|
end
|
||||||
@@ -165,7 +175,8 @@ function copyBoard()
|
|||||||
end
|
end
|
||||||
return data.encode("string","base64",data.compress("string","zlib",str))
|
return data.encode("string","base64",data.compress("string","zlib",str))
|
||||||
end
|
end
|
||||||
function pasteBoard(str)
|
function pasteBoard(str,page)
|
||||||
|
local F=FIELD[page or 1]
|
||||||
local _,__
|
local _,__
|
||||||
|
|
||||||
--Decode
|
--Decode
|
||||||
@@ -192,7 +203,7 @@ function pasteBoard(str)
|
|||||||
if __>26 then return end--Illegal blockid
|
if __>26 then return end--Illegal blockid
|
||||||
_=int(_/32)--Mode id
|
_=int(_/32)--Mode id
|
||||||
|
|
||||||
FIELD[fY][fX]=__
|
F[fY][fX]=__
|
||||||
if fX<10 then
|
if fX<10 then
|
||||||
fX=fX+1
|
fX=fX+1
|
||||||
else
|
else
|
||||||
@@ -205,7 +216,7 @@ function pasteBoard(str)
|
|||||||
|
|
||||||
for y=fY,20 do
|
for y=fY,20 do
|
||||||
for x=1,10 do
|
for x=1,10 do
|
||||||
FIELD[y][x]=0
|
F[y][x]=0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -82,18 +82,18 @@ function keyDown.customGame(key)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local FIELD=FIELD
|
|
||||||
function Pnt.customGame()
|
function Pnt.customGame()
|
||||||
--Field
|
--Field content
|
||||||
gc.push("transform")
|
gc.push("transform")
|
||||||
gc.translate(95,290)
|
gc.translate(95,290)
|
||||||
gc.scale(.5)
|
gc.scale(.5)
|
||||||
gc.setColor(1,1,1)
|
gc.setColor(1,1,1)
|
||||||
gc.setLineWidth(3)
|
gc.setLineWidth(3)
|
||||||
gc.rectangle("line",-2,-2,304,604)
|
gc.rectangle("line",-2,-2,304,604)
|
||||||
|
local F=FIELD[1]
|
||||||
local cross=puzzleMark[-1]
|
local cross=puzzleMark[-1]
|
||||||
for y=1,20 do for x=1,10 do
|
for y=1,20 do for x=1,10 do
|
||||||
local B=FIELD[y][x]
|
local B=F[y][x]
|
||||||
if B>0 then
|
if B>0 then
|
||||||
gc.draw(blockSkin[B],30*x-30,600-30*y)
|
gc.draw(blockSkin[B],30*x-30,600-30*y)
|
||||||
elseif B==-1 then
|
elseif B==-1 then
|
||||||
@@ -102,15 +102,22 @@ function Pnt.customGame()
|
|||||||
end end
|
end end
|
||||||
gc.pop()
|
gc.pop()
|
||||||
|
|
||||||
--Sequence
|
--Field
|
||||||
setFont(30)
|
|
||||||
gc.print(customEnv.sequence,330,510)
|
|
||||||
setFont(40)
|
setFont(40)
|
||||||
|
if #FIELD>1 then
|
||||||
|
gc.setColor(1,1,int(Timer()*6.26)%2)
|
||||||
|
gc.print("+",275,300)
|
||||||
|
gc.print(#FIELD-1,300,300)
|
||||||
|
end
|
||||||
|
|
||||||
|
--Sequence
|
||||||
if #BAG>0 then
|
if #BAG>0 then
|
||||||
gc.setColor(1,1,int(Timer()*6.26)%2)
|
gc.setColor(1,1,int(Timer()*6.26)%2)
|
||||||
gc.print("#",330,545)
|
gc.print("#",330,545)
|
||||||
gc.print(#BAG,360,545)
|
gc.print(#BAG,360,545)
|
||||||
end
|
end
|
||||||
|
setFont(30)
|
||||||
|
gc.print(customEnv.sequence,330,510)
|
||||||
|
|
||||||
--Sequence
|
--Sequence
|
||||||
if #MISSION>0 then
|
if #MISSION>0 then
|
||||||
|
|||||||
@@ -4,16 +4,20 @@ local ms,kb=love.mouse,love.keyboard
|
|||||||
local setFont=setFont
|
local setFont=setFont
|
||||||
local mStr=mStr
|
local mStr=mStr
|
||||||
|
|
||||||
local int=math.floor
|
local max,min,int=math.max,math.min,math.floor
|
||||||
local ins,rem=table.insert,table.remove
|
local ins,rem=table.insert,table.remove
|
||||||
local sub=string.sub
|
local sub=string.sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
local FIELD=FIELD
|
||||||
function sceneInit.custom_field()
|
function sceneInit.custom_field()
|
||||||
sceneTemp={
|
sceneTemp={
|
||||||
sure=0,
|
sure=0,
|
||||||
pen=1,
|
pen=1,
|
||||||
x=1,y=1,
|
x=1,y=1,
|
||||||
demo=false,
|
demo=false,
|
||||||
|
page=1,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -23,27 +27,27 @@ local penKey={
|
|||||||
a=17,s=18,d=19,f=20,g=21,h=22,j=23,k=24,
|
a=17,s=18,d=19,f=20,g=21,h=22,j=23,k=24,
|
||||||
z=0,x=-1,
|
z=0,x=-1,
|
||||||
}
|
}
|
||||||
local FIELD=FIELD
|
|
||||||
function mouseDown.custom_field(x,y)
|
function mouseDown.custom_field(x,y)
|
||||||
mouseMove.custom_field(x,y)
|
mouseMove.custom_field(x,y)
|
||||||
end
|
end
|
||||||
function mouseMove.custom_field(x,y)
|
function mouseMove.custom_field(x,y)
|
||||||
|
local S=sceneTemp
|
||||||
local sx,sy=int((x-200)/30)+1,20-int((y-60)/30)
|
local sx,sy=int((x-200)/30)+1,20-int((y-60)/30)
|
||||||
if sx<1 or sx>10 then sx=nil end
|
if sx<1 or sx>10 then sx=nil end
|
||||||
if sy<1 or sy>20 then sy=nil end
|
if sy<1 or sy>20 then sy=nil end
|
||||||
sceneTemp.x,sceneTemp.y=sx,sy
|
S.x,S.y=sx,sy
|
||||||
if sx and sy and ms.isDown(1,2,3)then
|
if sx and sy and ms.isDown(1,2,3)then
|
||||||
FIELD[sy][sx]=ms.isDown(1)and sceneTemp.pen or ms.isDown(2)and -1 or 0
|
FIELD[S.page][sy][sx]=ms.isDown(1)and S.pen or ms.isDown(2)and -1 or 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function wheelMoved.custom_field(_,y)
|
function wheelMoved.custom_field(_,y)
|
||||||
local pen=sceneTemp.pen
|
local pen=sceneTemp.pen
|
||||||
if y<0 then
|
if y<0 then
|
||||||
pen=pen+1
|
pen=pen+1
|
||||||
if pen==8 then pen=9 elseif pen==14 then pen=0 end
|
if pen==25 then pen=1 end
|
||||||
else
|
else
|
||||||
pen=pen-1
|
pen=pen-1
|
||||||
if pen==8 then pen=7 elseif pen==-1 then pen=13 end
|
if pen==0 then pen=24 end
|
||||||
end
|
end
|
||||||
sceneTemp.pen=pen
|
sceneTemp.pen=pen
|
||||||
end
|
end
|
||||||
@@ -51,16 +55,18 @@ function touchDown.custom_field(_,x,y)
|
|||||||
mouseMove.custom_field(x,y)
|
mouseMove.custom_field(x,y)
|
||||||
end
|
end
|
||||||
function touchMove.custom_field(_,x,y)
|
function touchMove.custom_field(_,x,y)
|
||||||
|
local S=sceneTemp
|
||||||
local sx,sy=int((x-200)/30)+1,20-int((y-60)/30)
|
local sx,sy=int((x-200)/30)+1,20-int((y-60)/30)
|
||||||
if sx<1 or sx>10 then sx=nil end
|
if sx<1 or sx>10 then sx=nil end
|
||||||
if sy<1 or sy>20 then sy=nil end
|
if sy<1 or sy>20 then sy=nil end
|
||||||
sceneTemp.x,sceneTemp.y=sx,sy
|
S.x,S.y=sx,sy
|
||||||
if sx and sy then
|
if sx and sy then
|
||||||
FIELD[sy][sx]=sceneTemp.pen
|
FIELD[S.page][sy][sx]=S.pen
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function keyDown.custom_field(key)
|
function keyDown.custom_field(key)
|
||||||
local sx,sy,pen=sceneTemp.x,sceneTemp.y,sceneTemp.pen
|
local S=sceneTemp
|
||||||
|
local sx,sy,pen=S.x,S.y,S.pen
|
||||||
if key=="up"or key=="down"or key=="left"or key=="right"then
|
if key=="up"or key=="down"or key=="left"or key=="right"then
|
||||||
if not sx then sx=1 end
|
if not sx then sx=1 end
|
||||||
if not sy then sy=1 end
|
if not sy then sy=1 end
|
||||||
@@ -70,30 +76,30 @@ function keyDown.custom_field(key)
|
|||||||
elseif key=="right"and sx<10 then sx=sx+1
|
elseif key=="right"and sx<10 then sx=sx+1
|
||||||
end
|
end
|
||||||
if kb.isDown("space")then
|
if kb.isDown("space")then
|
||||||
FIELD[sy][sx]=pen
|
FIELD[S.page][sy][sx]=pen
|
||||||
end
|
end
|
||||||
elseif key=="delete"then
|
elseif key=="delete"then
|
||||||
if sceneTemp.sure>20 then
|
if S.sure>20 then
|
||||||
for y=1,20 do for x=1,10 do FIELD[y][x]=0 end end
|
for y=1,20 do for x=1,10 do FIELD[S.page][y][x]=0 end end
|
||||||
sceneTemp.sure=0
|
S.sure=0
|
||||||
SFX.play("finesseError",.7)
|
SFX.play("finesseError",.7)
|
||||||
else
|
else
|
||||||
sceneTemp.sure=50
|
S.sure=50
|
||||||
end
|
end
|
||||||
elseif key=="space"then
|
elseif key=="space"then
|
||||||
if sx and sy then
|
if sx and sy then
|
||||||
FIELD[sy][sx]=pen
|
FIELD[S.page][sy][sx]=pen
|
||||||
end
|
end
|
||||||
elseif key=="escape"then
|
elseif key=="escape"then
|
||||||
SCN.back()
|
SCN.back()
|
||||||
elseif key=="j"then
|
elseif key=="j"then
|
||||||
sceneTemp.demo=not sceneTemp.demo
|
S.demo=not S.demo
|
||||||
elseif key=="k"then
|
elseif key=="k"then
|
||||||
ins(FIELD,1,{21,21,21,21,21,21,21,21,21,21})
|
ins(FIELD[S.page],1,{21,21,21,21,21,21,21,21,21,21})
|
||||||
FIELD[21]=nil
|
FIELD[S.page][21]=nil
|
||||||
SFX.play("blip")
|
SFX.play("blip")
|
||||||
elseif key=="l"then
|
elseif key=="l"then
|
||||||
local F=FIELD
|
local F=FIELD[S.page]
|
||||||
for i=20,1,-1 do
|
for i=20,1,-1 do
|
||||||
for j=1,10 do
|
for j=1,10 do
|
||||||
if F[i][j]<=0 then goto L end
|
if F[i][j]<=0 then goto L end
|
||||||
@@ -107,25 +113,45 @@ function keyDown.custom_field(key)
|
|||||||
repeat
|
repeat
|
||||||
F[#F+1]={0,0,0,0,0,0,0,0,0,0}
|
F[#F+1]={0,0,0,0,0,0,0,0,0,0}
|
||||||
until#F==20
|
until#F==20
|
||||||
SFX.play("clear_4",.8)
|
SFX.play("clear_3",.8)
|
||||||
SFX.play("fall",.8)
|
SFX.play("fall",.8)
|
||||||
end
|
end
|
||||||
elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then
|
elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then
|
||||||
sys.setClipboardText("Techmino Field:"..copyBoard())
|
sys.setClipboardText("Techmino Field:"..copyBoard(S.page))
|
||||||
LOG.print(text.copySuccess,color.green)
|
LOG.print(text.copySuccess,color.green)
|
||||||
elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then
|
elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then
|
||||||
local str=sys.getClipboardText()
|
local str=sys.getClipboardText()
|
||||||
local p=string.find(str,":")--ptr*
|
local p=string.find(str,":")--ptr*
|
||||||
if p then str=sub(str,p+1)end
|
if p then str=sub(str,p+1)end
|
||||||
if pasteBoard(str)then
|
if pasteBoard(str,S.page)then
|
||||||
LOG.print(text.pasteSuccess,color.green)
|
LOG.print(text.pasteSuccess,color.green)
|
||||||
else
|
else
|
||||||
LOG.print(text.dataCorrupted,color.red)
|
LOG.print(text.dataCorrupted,color.red)
|
||||||
end
|
end
|
||||||
|
elseif key=="tab"or key=="sTab"then
|
||||||
|
if key=="sTab"or kb.isDown("lshift","rshift")then
|
||||||
|
S.page=max(S.page-1,1)
|
||||||
|
else
|
||||||
|
S.page=min(S.page+1,#FIELD)
|
||||||
|
end
|
||||||
|
elseif key=="n"then
|
||||||
|
ins(FIELD,S.page+1,newBoard(FIELD[S.page]))
|
||||||
|
S.page=S.page+1
|
||||||
|
SFX.play("blip_1",.8)
|
||||||
|
sysFX.newShade(.3,.5,1,.5,200,60,300,600)
|
||||||
|
elseif key=="m"then
|
||||||
|
rem(FIELD,S.page)
|
||||||
|
S.page=max(S.page-1,1)
|
||||||
|
if not FIELD[1]then
|
||||||
|
ins(FIELD,newBoard())
|
||||||
|
end
|
||||||
|
sysFX.newShade(.3,1,.5,.5,200,60,300,600)
|
||||||
|
SFX.play("clear_4",.8)
|
||||||
|
SFX.play("fall",.8)
|
||||||
else
|
else
|
||||||
pen=penKey[key]or pen
|
pen=penKey[key]or pen
|
||||||
end
|
end
|
||||||
sceneTemp.x,sceneTemp.y,sceneTemp.pen=sx,sy,pen
|
S.x,S.y,S.pen=sx,sy,pen
|
||||||
end
|
end
|
||||||
|
|
||||||
function Tmr.custom_field()
|
function Tmr.custom_field()
|
||||||
@@ -136,48 +162,60 @@ function Pnt.custom_field()
|
|||||||
local S=sceneTemp
|
local S=sceneTemp
|
||||||
local sx,sy=S.x,S.y
|
local sx,sy=S.x,S.y
|
||||||
|
|
||||||
--Field
|
|
||||||
gc.translate(200,60)
|
gc.translate(200,60)
|
||||||
|
|
||||||
|
--Draw grid
|
||||||
gc.setColor(1,1,1,.2)
|
gc.setColor(1,1,1,.2)
|
||||||
gc.setLineWidth(1)
|
gc.setLineWidth(1)
|
||||||
for x=1,9 do gc.line(30*x,0,30*x,600)end
|
for x=1,9 do gc.line(30*x,0,30*x,600)end
|
||||||
for y=0,19 do gc.line(0,30*y,300,30*y)end
|
for y=0,19 do gc.line(0,30*y,300,30*y)end
|
||||||
|
|
||||||
|
--Draw field
|
||||||
gc.setColor(1,1,1)
|
gc.setColor(1,1,1)
|
||||||
gc.setLineWidth(3)
|
gc.setLineWidth(3)
|
||||||
gc.rectangle("line",-2,-2,304,604)
|
gc.rectangle("line",-2,-2,304,604)
|
||||||
gc.setLineWidth(2)
|
gc.setLineWidth(2)
|
||||||
local cross=puzzleMark[-1]
|
local cross=puzzleMark[-1]
|
||||||
|
local F=FIELD[S.page]
|
||||||
for y=1,20 do for x=1,10 do
|
for y=1,20 do for x=1,10 do
|
||||||
local B=FIELD[y][x]
|
local B=F[y][x]
|
||||||
if B>0 then
|
if B>0 then
|
||||||
gc.draw(blockSkin[B],30*x-30,600-30*y)
|
gc.draw(blockSkin[B],30*x-30,600-30*y)
|
||||||
elseif B==-1 and not S.demo then
|
elseif B==-1 and not S.demo then
|
||||||
gc.draw(cross,30*x-30,600-30*y)
|
gc.draw(cross,30*x-30,600-30*y)
|
||||||
end
|
end
|
||||||
end end
|
end end
|
||||||
|
|
||||||
|
--Draw pen
|
||||||
if sx and sy then
|
if sx and sy then
|
||||||
gc.setLineWidth(2)
|
gc.setLineWidth(2)
|
||||||
gc.rectangle("line",30*sx-30,600-30*sy,30,30)
|
gc.rectangle("line",30*sx-30,600-30*sy,30,30)
|
||||||
end
|
end
|
||||||
gc.translate(-200,-60)
|
gc.translate(-200,-60)
|
||||||
|
|
||||||
--Pen
|
--Draw page
|
||||||
|
setFont(55)
|
||||||
|
mStr(S.page,100,510)
|
||||||
|
mStr(#FIELD,100,600)
|
||||||
|
gc.rectangle("fill",50,590,100,6)
|
||||||
|
|
||||||
|
--Draw pen color
|
||||||
local pen=S.pen
|
local pen=S.pen
|
||||||
if pen>0 then
|
if pen>0 then
|
||||||
gc.setLineWidth(13)
|
gc.setLineWidth(13)
|
||||||
gc.setColor(SKIN.libColor[pen])
|
gc.setColor(SKIN.libColor[pen])
|
||||||
gc.rectangle("line",565,500,70,70)
|
gc.rectangle("line",545,495,70,70)
|
||||||
elseif pen==-1 then
|
elseif pen==-1 then
|
||||||
gc.setLineWidth(5)
|
gc.setLineWidth(5)
|
||||||
gc.setColor(.9,.9,.9)
|
gc.setColor(.9,.9,.9)
|
||||||
gc.line(575,510,625,560)
|
gc.line(555,505,605,555)
|
||||||
gc.line(575,560,625,510)
|
gc.line(555,555,605,505)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Confirm reset
|
--Confirm reset
|
||||||
if S.sure>0 then
|
if S.sure>0 then
|
||||||
gc.setColor(1,1,1,S.sure*.02)
|
gc.setColor(1,1,1,S.sure*.02)
|
||||||
gc.draw(drawableText.question,1180,340)
|
gc.draw(drawableText.question,1145,330)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Block name
|
--Block name
|
||||||
|
|||||||
Reference in New Issue
Block a user