整理代码,添加设置方块初始方向动画
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
local scene={}
|
||||
|
||||
local sure
|
||||
|
||||
function scene.sceneInit()
|
||||
sure=false
|
||||
end
|
||||
function scene.keyDown(key)
|
||||
LOG.print("keyPress: ["..key.."]")
|
||||
end
|
||||
|
||||
local function dumpCB(T)
|
||||
love.system.setClipboardText(
|
||||
love.data.encode(
|
||||
@@ -37,9 +28,6 @@ local function parseCB()
|
||||
return s()
|
||||
end
|
||||
end
|
||||
local function HIDE()
|
||||
return not sure
|
||||
end
|
||||
scene.widgetList={
|
||||
WIDGET.newButton{name="exportUnlock", x=190,y=150,w=280,h=100,color="lGreen",font=25,code=function()dumpCB(RANKS)end},
|
||||
WIDGET.newButton{name="exportData", x=490,y=150,w=280,h=100,color="lGreen",font=25,code=function()dumpCB(STAT)end},
|
||||
@@ -87,7 +75,12 @@ scene.widgetList={
|
||||
end
|
||||
end},
|
||||
|
||||
WIDGET.newButton{name="reset", x=640,y=460,w=280,h=100,color="lRed",font=40,code=function()sure=true end,hide=function()return sure end},
|
||||
WIDGET.newButton{name="reset", x=640,y=460,w=280,h=100,color="lRed",font=40,code=function()
|
||||
scene.widgetList.reset.hide=true
|
||||
scene.widgetList.resetUnlock.hide=false
|
||||
scene.widgetList.resetRecord.hide=false
|
||||
scene.widgetList.resetData.hide=false
|
||||
end},
|
||||
WIDGET.newButton{name="resetUnlock", x=340,y=460,w=280,h=100,color="red",
|
||||
code=function()
|
||||
love.filesystem.remove("conf/unlock")
|
||||
@@ -95,8 +88,7 @@ scene.widgetList={
|
||||
TEXT.show("rank resetted",640,300,60,"stretch",.4)
|
||||
LOG.print("effected after restart game","message")
|
||||
LOG.print("fresh a rank to get data back","message")
|
||||
end,
|
||||
hide=HIDE},
|
||||
end,hide=true},
|
||||
WIDGET.newButton{name="resetRecord", x=640,y=460,w=280,h=100,color="red",
|
||||
code=function()
|
||||
for _,name in next,love.filesystem.getDirectoryItems("record")do
|
||||
@@ -105,8 +97,7 @@ scene.widgetList={
|
||||
SFX.play("clear_4")SFX.play("finesseError_long")
|
||||
TEXT.show("record data resetted",640,300,60,"stretch",.4)
|
||||
LOG.print("fresh a record list to get one list back","message")
|
||||
end,
|
||||
hide=HIDE},
|
||||
end,hide=true},
|
||||
WIDGET.newButton{name="resetData", x=940,y=460,w=280,h=100,color="red",
|
||||
code=function()
|
||||
love.filesystem.remove("conf/data")
|
||||
@@ -114,8 +105,7 @@ scene.widgetList={
|
||||
TEXT.show("game data resetted",640,300,60,"stretch",.4)
|
||||
LOG.print("effected after restart game","message")
|
||||
LOG.print("play one game to get data back","message")
|
||||
end,
|
||||
hide=HIDE},
|
||||
end,hide=true},
|
||||
|
||||
WIDGET.newButton{name="back", x=640,y=620,w=200,h=80,font=40,code=backScene},
|
||||
}
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
local gc=love.graphics
|
||||
local int=math.floor
|
||||
local sin=math.sin
|
||||
|
||||
local minoRot={0,0,0,0,0,0,0}
|
||||
local minoRot0={}
|
||||
|
||||
local scene={}
|
||||
|
||||
function scene.sceneInit()
|
||||
for i=1,7 do
|
||||
minoRot0[i]=SETTING.face[i]*1.57
|
||||
end
|
||||
end
|
||||
|
||||
function scene.update()
|
||||
for i=1,7 do
|
||||
minoRot[i]=minoRot[i]*.8+minoRot0[i]*.2
|
||||
end
|
||||
end
|
||||
function scene.draw()
|
||||
local t=TIME()
|
||||
gc.setColor(1,1,1)
|
||||
local texture=SKIN.curText
|
||||
for N=1,7 do
|
||||
for n=1,7 do
|
||||
gc.push("transform")
|
||||
gc.translate(-10+140*N,340)
|
||||
gc.rotate(SETTING.face[N]*1.57+sin(t*3-N*.5)*.08)
|
||||
local color=SETTING.skin[N]
|
||||
local B=BLOCKS[N][0]
|
||||
local x,y=-45-SCS[N][0][2]*30,15+SCS[N][0][1]*30
|
||||
gc.translate(-10+140*n,340)
|
||||
gc.rotate(minoRot[n]+sin(t*3-n*.5)*.08)
|
||||
local color=SETTING.skin[n]
|
||||
local B=BLOCKS[n][0]
|
||||
local x,y=-45-SCS[n][0][2]*30,15+SCS[n][0][1]*30
|
||||
local col=#B[1]
|
||||
for i=1,#B do for j=1,col do
|
||||
if B[i][j]then
|
||||
@@ -29,38 +44,46 @@ function scene.draw()
|
||||
gc.draw(texture[17],930,610+sin(2.6*t-6)*5,nil,2)
|
||||
end
|
||||
|
||||
local function prevSkin(n)return function()SKIN.prev(n)end end
|
||||
local function nextSkin(n)return function()SKIN.next(n)end end
|
||||
local function nextDir(n)return function()SKIN.rotate(n)end end
|
||||
local function prevSkin(i)
|
||||
SETTING.skin[i]=(SETTING.skin[i]-2)%16+1
|
||||
end
|
||||
local function nextSkin(i)
|
||||
SETTING.skin[i]=SETTING.skin[i]%16+1
|
||||
end
|
||||
local function nextDir(i)
|
||||
SETTING.face[i]=(SETTING.face[i]+1)%4
|
||||
minoRot0[i]=minoRot0[i]+1.5707963
|
||||
SFX.play("rotate")
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
WIDGET.newText{name="title", x=80,y=50,font=70,align="L"},
|
||||
|
||||
WIDGET.newButton{name="prev", x=700,y=100,w=140,h=100,fText="←",font=50,code=function()SKIN.prevSet()end},
|
||||
WIDGET.newButton{name="next", x=860,y=100,w=140,h=100,fText="→",font=50,code=function()SKIN.nextSet()end},
|
||||
WIDGET.newButton{name="prev1", x=130,y=230,w=90,h=65,fText="↑",code=prevSkin(1)},
|
||||
WIDGET.newButton{name="prev2", x=270,y=230,w=90,h=65,fText="↑",code=prevSkin(2)},
|
||||
WIDGET.newButton{name="prev3", x=410,y=230,w=90,h=65,fText="↑",code=prevSkin(3)},
|
||||
WIDGET.newButton{name="prev4", x=550,y=230,w=90,h=65,fText="↑",code=prevSkin(4)},
|
||||
WIDGET.newButton{name="prev5", x=690,y=230,w=90,h=65,fText="↑",code=prevSkin(5)},
|
||||
WIDGET.newButton{name="prev6", x=830,y=230,w=90,h=65,fText="↑",code=prevSkin(6)},
|
||||
WIDGET.newButton{name="prev7", x=970,y=230,w=90,h=65,fText="↑",code=prevSkin(7)},
|
||||
WIDGET.newButton{name="prev1", x=130,y=230,w=90,h=65,fText="↑",code=function()prevSkin(1)end},
|
||||
WIDGET.newButton{name="prev2", x=270,y=230,w=90,h=65,fText="↑",code=function()prevSkin(2)end},
|
||||
WIDGET.newButton{name="prev3", x=410,y=230,w=90,h=65,fText="↑",code=function()prevSkin(3)end},
|
||||
WIDGET.newButton{name="prev4", x=550,y=230,w=90,h=65,fText="↑",code=function()prevSkin(4)end},
|
||||
WIDGET.newButton{name="prev5", x=690,y=230,w=90,h=65,fText="↑",code=function()prevSkin(5)end},
|
||||
WIDGET.newButton{name="prev6", x=830,y=230,w=90,h=65,fText="↑",code=function()prevSkin(6)end},
|
||||
WIDGET.newButton{name="prev7", x=970,y=230,w=90,h=65,fText="↑",code=function()prevSkin(7)end},
|
||||
|
||||
WIDGET.newButton{name="next1", x=130,y=450,w=90,h=65,fText="↓",code=nextSkin(1)},
|
||||
WIDGET.newButton{name="next2", x=270,y=450,w=90,h=65,fText="↓",code=nextSkin(2)},
|
||||
WIDGET.newButton{name="next3", x=410,y=450,w=90,h=65,fText="↓",code=nextSkin(3)},
|
||||
WIDGET.newButton{name="next4", x=550,y=450,w=90,h=65,fText="↓",code=nextSkin(4)},
|
||||
WIDGET.newButton{name="next5", x=690,y=450,w=90,h=65,fText="↓",code=nextSkin(5)},
|
||||
WIDGET.newButton{name="next6", x=830,y=450,w=90,h=65,fText="↓",code=nextSkin(6)},
|
||||
WIDGET.newButton{name="next7", x=970,y=450,w=90,h=65,fText="↓",code=nextSkin(7)},
|
||||
WIDGET.newButton{name="next1", x=130,y=450,w=90,h=65,fText="↓",code=function()nextSkin(1)end},
|
||||
WIDGET.newButton{name="next2", x=270,y=450,w=90,h=65,fText="↓",code=function()nextSkin(2)end},
|
||||
WIDGET.newButton{name="next3", x=410,y=450,w=90,h=65,fText="↓",code=function()nextSkin(3)end},
|
||||
WIDGET.newButton{name="next4", x=550,y=450,w=90,h=65,fText="↓",code=function()nextSkin(4)end},
|
||||
WIDGET.newButton{name="next5", x=690,y=450,w=90,h=65,fText="↓",code=function()nextSkin(5)end},
|
||||
WIDGET.newButton{name="next6", x=830,y=450,w=90,h=65,fText="↓",code=function()nextSkin(6)end},
|
||||
WIDGET.newButton{name="next7", x=970,y=450,w=90,h=65,fText="↓",code=function()nextSkin(7)end},
|
||||
|
||||
WIDGET.newButton{name="spin1", x=130,y=540,w=90,h=65,code=nextDir(1)},
|
||||
WIDGET.newButton{name="spin2", x=270,y=540,w=90,h=65,code=nextDir(2)},
|
||||
WIDGET.newButton{name="spin3", x=410,y=540,w=90,h=65,code=nextDir(3)},
|
||||
WIDGET.newButton{name="spin4", x=550,y=540,w=90,h=65,code=nextDir(4)},
|
||||
WIDGET.newButton{name="spin5", x=690,y=540,w=90,h=65,code=nextDir(5)},
|
||||
--WIDGET.newButton{name="spin6",x=825,y=540,w=90,h=65,code=nextDir(6)},--Cannot rotate O
|
||||
WIDGET.newButton{name="spin7", x=970,y=540,w=90,h=65,code=nextDir(7)},
|
||||
WIDGET.newButton{name="spin1", x=130,y=540,w=90,h=65,code=function()nextDir(1)end},
|
||||
WIDGET.newButton{name="spin2", x=270,y=540,w=90,h=65,code=function()nextDir(2)end},
|
||||
WIDGET.newButton{name="spin3", x=410,y=540,w=90,h=65,code=function()nextDir(3)end},
|
||||
WIDGET.newButton{name="spin4", x=550,y=540,w=90,h=65,code=function()nextDir(4)end},
|
||||
WIDGET.newButton{name="spin5", x=690,y=540,w=90,h=65,code=function()nextDir(5)end},
|
||||
--WIDGET.newButton{name="spin6",x=825,y=540,w=90,h=65,code=function()nextDir(6)end},--Cannot rotate O
|
||||
WIDGET.newButton{name="spin7", x=970,y=540,w=90,h=65,code=function()nextDir(7)end},
|
||||
|
||||
WIDGET.newButton{name="skinR", x=200,y=640,w=220,h=80,color="lPurple",font=35,
|
||||
code=function()
|
||||
@@ -72,6 +95,9 @@ scene.widgetList={
|
||||
for i=1,29 do
|
||||
SETTING.face[i]=0
|
||||
end
|
||||
for i=1,7 do
|
||||
minoRot0[i]=(int(minoRot0[i]/6.2831853)+(minoRot0[i]%6.2831853>4 and 1 or 0))*6.2831853
|
||||
end
|
||||
SFX.play("hold")
|
||||
end},
|
||||
WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=40,code=backScene},
|
||||
|
||||
@@ -66,18 +66,6 @@ function SKIN.init(list)
|
||||
_=list[_]
|
||||
TEXT.show(_,1100,100,int(300/#_)+5,"fly")
|
||||
end
|
||||
function SKIN.prev(i)--Prev skin for [i]
|
||||
local _=SETTING.skin
|
||||
_[i]=(_[i]-2)%16+1
|
||||
end
|
||||
function SKIN.next(i)--Next skin for [i]
|
||||
local _=SETTING.skin
|
||||
_[i]=_[i]%16+1
|
||||
end
|
||||
function SKIN.rotate(i)--Change direction of [i]
|
||||
SETTING.face[i]=(SETTING.face[i]+1)%4
|
||||
SFX.play("rotate")
|
||||
end
|
||||
function SKIN.change(i)--Change to skin_set[i]
|
||||
SKIN.curText=SKIN.lib[i]
|
||||
SKIN.curTextMini=SKIN.libMini[i]
|
||||
|
||||
Reference in New Issue
Block a user