0.8.16Fantastic Global Update
This commit is contained in:
300
parts/ai.lua
Normal file
300
parts/ai.lua
Normal file
@@ -0,0 +1,300 @@
|
||||
--[[
|
||||
HighestBlock
|
||||
HorizontalTransitions
|
||||
VerticalTransitions
|
||||
BlockedCells
|
||||
Wells
|
||||
FilledLines
|
||||
4deepShape
|
||||
BlockedWells;
|
||||
]]
|
||||
local int,ceil,min,abs,rnd=math.floor,math.ceil,math.min,math.abs,math.random
|
||||
local ins,rem=table.insert,table.remove
|
||||
local Timer=love.timer.getTime
|
||||
-- controlname:
|
||||
-- 1~5:mL,mR,rR,rL,rF,
|
||||
-- 6~10:hD,sD,H,A,R,
|
||||
-- 11~13:LL,RR,DD
|
||||
local blockPos={4,4,4,4,4,5,4}
|
||||
local scs={{1,2},{1,2},{1,2},{1,2},{1,2},{1.5,1.5},{0.5,2.5}}
|
||||
-------------------------------------------------Cold clear
|
||||
local CCblockID={4,3,5,6,1,2,0}
|
||||
if system~="Windows"then goto SKIP end
|
||||
require("CCloader")
|
||||
BOT={
|
||||
getConf= cc.get_default_config ,--()options,weights
|
||||
--setConf= cc.set_options ,--(options,hold,20g,bag7)
|
||||
|
||||
new= cc.launch_async ,--(options,weights)bot
|
||||
addNext= cc.add_next_piece_async ,--(bot,piece)
|
||||
update= cc.reset_async ,--(bot,field,b2b,combo)
|
||||
think= cc.request_next_move ,--(bot)
|
||||
getMove= cc.poll_next_move ,--(bot)success,hold,move
|
||||
ifDead= cc.is_dead_async ,--(bot)dead
|
||||
destroy= cc.destroy_async ,--(bot)
|
||||
|
||||
setHold= cc.set_hold ,--(opt,bool)
|
||||
set20G= cc.set_20g ,--(opt,bool)
|
||||
setBag= cc.set_bag7 ,--(opt,bool)
|
||||
setNode= cc.set_max_nodes ,--(opt,bool)
|
||||
free= cc.free ,--(opt/wei)
|
||||
}
|
||||
function CC_updateField(P)
|
||||
local F,i={},1
|
||||
for y=1,#P.field do
|
||||
for x=1,10 do
|
||||
F[i],i=P.field[y][x]>0,i+1
|
||||
end
|
||||
end
|
||||
while i<400 do
|
||||
F[i],i=false,i+1
|
||||
end
|
||||
BOT.update(P.AI_bot,F,P.b2b>=100,P.combo)
|
||||
end
|
||||
function CC_switch20G(P)
|
||||
P.AIdata._20G=true
|
||||
P.AI_keys={}
|
||||
BOT.destroy(P.AI_bot)
|
||||
local opt,wei=BOT.getConf()
|
||||
BOT.setHold(opt,P.AIdata.hold)
|
||||
BOT.set20G(opt,P.AIdata._20G)
|
||||
BOT.setBag(opt,P.AIdata.bag7)
|
||||
BOT.setNode(opt,P.AIdata.node)
|
||||
P.AI_bot=BOT.new(opt,wei)
|
||||
BOT.free(opt)BOT.free(wei)
|
||||
for i=1,P.AIdata.next do
|
||||
BOT.addNext(P.AI_bot,CCblockID[P.next[i].id])
|
||||
end
|
||||
CC_updateField(P)
|
||||
P.hd={bk={{}},id=0,color=0,name=0}P.holded=false
|
||||
P.cur=rem(P.next,1)
|
||||
P.sc,P.dir=scs[P.cur.id],0
|
||||
P.r,P.c=#P.cur.bk,#P.cur.bk[1]
|
||||
P.curX,P.curY=blockPos[P.cur.id],21+ceil(P.fieldBeneath/30)-P.r+min(int(#P.field*.2),2)
|
||||
|
||||
P:newNext()
|
||||
BOT.addNext(P.AI_bot,CCblockID[P.next[P.AIdata.next].id])
|
||||
collectgarbage()
|
||||
end
|
||||
::SKIP::
|
||||
-------------------------------------------------⑨Stack setup
|
||||
local dirCount={1,1,3,3,3,0,1}
|
||||
local spinOffset={
|
||||
{[0]=0,1,0,0},--Z
|
||||
{[0]=0,1,0,0},--L
|
||||
{[0]=0,1,0,0},--J
|
||||
{[0]=0,1,0,0},--T
|
||||
{[0]=0,1,0,0},--S
|
||||
{[0]=0,0,0,0},--O
|
||||
{[0]=0,2,0,1},--I
|
||||
}
|
||||
local FCL={
|
||||
[1]={
|
||||
{{11},{11,2},{1},{},{2},{2,2},{12,1},{12}},
|
||||
{{11,4},{11,3},{11,2,3},{4},{3},{2,3},{2,2,3},{12,4},{12,3}},
|
||||
},
|
||||
[3]={
|
||||
{{11},{11,2},{1},{},{2},{2,2},{12,1},{12},},
|
||||
{{3,11},{11,3},{11,2,3},{1,3},{3},{2,3},{2,2,3},{12,1,3},{12,3},},
|
||||
{{11,5},{11,2,5},{1,5},{5},{2,5},{2,2,5},{12,1,5},{12,5},},
|
||||
{{11,4},{11,2,4},{1,4},{4},{2,4},{2,2,4},{12,1,4},{12,4},{4,12},},
|
||||
},
|
||||
[6]={
|
||||
{{11},{11,2},{1,1},{1},{},{2},{2,2},{12,1},{12},},
|
||||
},
|
||||
[7]={
|
||||
{{11},{11,2},{1},{},{2},{12,1},{12},},
|
||||
{{4,11},{11,4},{11,3},{1,4},{4},{3},{2,3},{12,4},{12,3},{3,12},},
|
||||
},
|
||||
}FCL[2],FCL[4],FCL[5]=FCL[1],FCL[3],FCL[3]
|
||||
local LclearScore={[0]=0,-200,-120,-80,200}
|
||||
local HclearScore={[0]=0,100,140,200,500}
|
||||
local function ifoverlapAI(f,bk,x,y)
|
||||
if y<1 then return true end
|
||||
if y>#f then return end
|
||||
for i=1,#bk do for j=1,#bk[1]do
|
||||
if f[y+i-1]and bk[i][j]and f[y+i-1][x+j-1]>0 then return true end
|
||||
end end
|
||||
end
|
||||
local function resetField(f0,f,start)
|
||||
for _=#f,start,-1 do
|
||||
freeRow.discard(f[_])
|
||||
f[_]=nil
|
||||
end
|
||||
for i=start,#f0 do
|
||||
f[i]=freeRow.get(0)
|
||||
for j=1,10 do
|
||||
f[i][j]=f0[i][j]
|
||||
end
|
||||
end
|
||||
end
|
||||
local function getScore(field,cb,cy)
|
||||
local score=0
|
||||
local highest=0
|
||||
local height=freeRow.get(0)
|
||||
local clear=0
|
||||
local hole=0
|
||||
|
||||
for i=cy+#cb-1,cy,-1 do
|
||||
for j=1,10 do
|
||||
if field[i][j]==0 then goto L end
|
||||
end
|
||||
freeRow.discard(rem(field,i))
|
||||
clear=clear+1
|
||||
::L::
|
||||
end
|
||||
if #field==0 then return 1e99 end--PC
|
||||
for x=1,10 do
|
||||
local h=#field
|
||||
while field[h][x]==0 and h>1 do
|
||||
h=h-1
|
||||
end
|
||||
height[x]=h
|
||||
if x>3 and x<8 and h>highest then highest=h end
|
||||
if h>1 then
|
||||
for h=h-1,1,-1 do
|
||||
if field[h][x]==0 then
|
||||
hole=hole+1
|
||||
if hole==5 then break end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local sdh=0
|
||||
local h1,mh1=0,0
|
||||
for x=1,9 do
|
||||
local dh=abs(height[x]-height[x+1])
|
||||
if dh==1 then
|
||||
h1=h1+1
|
||||
if h1>mh1 then mh1=h1 end
|
||||
else
|
||||
h1=0
|
||||
end
|
||||
sdh=sdh+min(dh^1.6,20)
|
||||
end
|
||||
freeRow.discard(height)
|
||||
score=
|
||||
-#field*30
|
||||
-#cb*15
|
||||
+(#field>10 and
|
||||
HclearScore[clear]--Clearing
|
||||
-hole*70--Hole
|
||||
-cy*50--Height
|
||||
-sdh--∫Δh
|
||||
or
|
||||
LclearScore[clear]
|
||||
-hole*100
|
||||
-cy*40
|
||||
-sdh*3
|
||||
)
|
||||
if #field>6 then score=score-highest*5+20 end
|
||||
if mh1>3 then score=score-20-mh1*30 end
|
||||
return score
|
||||
end
|
||||
-------------------------------------------------
|
||||
AI_think={
|
||||
["9S"]={
|
||||
function(P,ctrl)
|
||||
local Tfield={}--test field
|
||||
local field_org=P.field
|
||||
for i=1,#field_org do
|
||||
Tfield[i]=freeRow.get(0)
|
||||
for j=1,10 do
|
||||
Tfield[i][j]=field_org[i][j]
|
||||
end
|
||||
end
|
||||
local best={x=1,dir=0,hold=false,score=-1e99}
|
||||
for ifhold=0,P.gameEnv.hold and 1 or 0 do
|
||||
local bn=ifhold==0 and P.cur.id or P.hd.id>0 and P.hd.id or P.next[1].id
|
||||
for dir=0,dirCount[bn] do--each dir
|
||||
local cb=blocks[bn][dir]
|
||||
for cx=1,11-#cb[1]do--each pos
|
||||
local cy=#Tfield+1
|
||||
while not ifoverlapAI(Tfield,cb,cx,cy-1)do
|
||||
cy=cy-1
|
||||
end--move to bottom
|
||||
for i=1,#cb do
|
||||
local y=cy+i-1
|
||||
if not Tfield[y]then Tfield[y]=freeRow.get(0)end
|
||||
for j=1,#cb[1]do
|
||||
if cb[i][j]then
|
||||
Tfield[y][cx+j-1]=1
|
||||
end
|
||||
end
|
||||
end--simulate lock
|
||||
local score=getScore(Tfield,cb,cy)
|
||||
if score>best.score then
|
||||
best={bn=bn,x=cx,dir=dir,hold=ifhold==1,score=score}
|
||||
end
|
||||
resetField(field_org,Tfield,cy)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
::L::
|
||||
if #Tfield>0 then
|
||||
freeRow.discard(rem(Tfield,1))
|
||||
goto L
|
||||
end--Release cache
|
||||
local p=#ctrl+1
|
||||
if best.hold then
|
||||
ctrl[p]=8
|
||||
p=p+1
|
||||
end
|
||||
local l=FCL[best.bn][best.dir+1][best.x]
|
||||
for i=1,#l do
|
||||
ctrl[p]=l[i]
|
||||
p=p+1
|
||||
end
|
||||
ctrl[p]=6
|
||||
return 2
|
||||
end,
|
||||
function(P)
|
||||
P.AI_delay=P.AI_delay0
|
||||
if Timer()-P.modeData.point>P.modeData.event then
|
||||
P.modeData.point=Timer()
|
||||
P.modeData.event=P.AI_delay0+rnd(5,15)
|
||||
P:changeAtkMode(rnd()<.85 and 1 or #P.atker>3 and 4 or rnd()<.3 and 2 or 3)
|
||||
end
|
||||
return 1
|
||||
end,
|
||||
},
|
||||
["CC"]={
|
||||
function(P)
|
||||
if P.AI_needFresh then
|
||||
CC_updateField(P)
|
||||
P.AI_needFresh=false
|
||||
end
|
||||
BOT.think(P.AI_bot)
|
||||
return 2
|
||||
end,--start thinking
|
||||
function(P,ctrl)
|
||||
if BOT.ifDead(P.AI_bot)then ins(ctrl,6)return 3 end
|
||||
local success,hold,move=BOT.getMove(P.AI_bot)
|
||||
if success then
|
||||
if hold then ctrl[1]=8 end--Hold
|
||||
while move[1]do
|
||||
local m=rem(move,1)
|
||||
if m<4 then
|
||||
ins(ctrl,m+1)
|
||||
elseif not P.AIdata._20G then
|
||||
ins(ctrl,13)
|
||||
end
|
||||
end
|
||||
ins(ctrl,6)
|
||||
return 3
|
||||
else
|
||||
return 2--stay this stage
|
||||
end
|
||||
end,--poll keys
|
||||
function(P)
|
||||
P.AI_delay=P.AI_delay0
|
||||
if Timer()-P.modeData.point>P.modeData.event then
|
||||
P.modeData.point=Timer()
|
||||
P.modeData.event=P.AI_delay0+rnd(5,15)
|
||||
P:changeAtkMode(rnd()<.85 and 1 or #P.atker>3 and 4 or rnd()<.3 and 2 or 3)
|
||||
end
|
||||
return 1
|
||||
end,--check if time to change target
|
||||
},
|
||||
}--AI think stage
|
||||
240
parts/bg.lua
Normal file
240
parts/bg.lua
Normal file
@@ -0,0 +1,240 @@
|
||||
local gc=love.graphics
|
||||
local int,ceil,rnd,abs=math.floor,math.ceil,math.random,math.abs
|
||||
local max,min,sin,cos=math.max,math.min,math.sin,math.cos
|
||||
|
||||
local scr=scr
|
||||
|
||||
local BGinit,BGresize,BGupdate,BGdraw,BGdiscard={},{},{},{},{}
|
||||
local BGvars={_G=_G}
|
||||
|
||||
function BGdraw.none()
|
||||
gc.clear(.15,.15,.15)
|
||||
end
|
||||
|
||||
function BGdraw.grey()
|
||||
gc.clear(.3,.3,.3)
|
||||
end
|
||||
|
||||
function BGinit.glow()
|
||||
t=0
|
||||
end
|
||||
function BGupdate.glow(dt)
|
||||
t=t+dt
|
||||
end
|
||||
function BGdraw.glow()
|
||||
local t=(sin(t*.5)+sin(t*.7)+sin(t*.9+1)+sin(t*1.5)+sin(t*2+10))*.08
|
||||
gc.clear(t,t,t)
|
||||
end
|
||||
|
||||
function BGinit.rgb()
|
||||
t=0
|
||||
end
|
||||
function BGupdate.rgb(dt)
|
||||
t=t+dt
|
||||
end
|
||||
function BGdraw.rgb()
|
||||
gc.clear(
|
||||
sin(t*1.2)*.15+.2,
|
||||
sin(t*1.5)*.15+.2,
|
||||
sin(t*1.9)*.15+.2
|
||||
)
|
||||
end
|
||||
|
||||
function BGinit.strap()
|
||||
t=0
|
||||
img=_G.IMG.gameBG2
|
||||
end
|
||||
function BGupdate.strap(dt)
|
||||
t=t+dt
|
||||
end
|
||||
function BGdraw.strap()
|
||||
gc.setColor(.5,.5,.5)
|
||||
local x=t%16*-64
|
||||
::L::
|
||||
gc.draw(img,x,0,nil,8,scr.h)
|
||||
x=x+1024--image width*8
|
||||
if x<scr.w then goto L end
|
||||
end
|
||||
|
||||
function BGinit.flink()
|
||||
t=0
|
||||
end
|
||||
function BGupdate.flink(dt)
|
||||
t=t+dt
|
||||
end
|
||||
function BGdraw.flink()
|
||||
local t=.13-t%3%1.7
|
||||
if t<.2 then gc.clear(t,t,t)
|
||||
else gc.clear(0,0,0)
|
||||
end
|
||||
end
|
||||
|
||||
function BGinit.game1()
|
||||
t=0
|
||||
img=_G.IMG.gameBG1
|
||||
end
|
||||
function BGupdate.game1(dt)
|
||||
t=t+dt
|
||||
end
|
||||
function BGdraw.game1()
|
||||
gc.setColor(.5,.5,.5)
|
||||
gc.draw(img,scr.w*.5,scr.h*.5,t*.15,scr.rad*.0625,nil,16,16)
|
||||
end--Rainbow
|
||||
|
||||
function BGinit.game2()
|
||||
t=0
|
||||
img=_G.IMG.gameBG1
|
||||
end
|
||||
function BGupdate.game2(dt)
|
||||
t=t+dt
|
||||
end
|
||||
function BGdraw.game2()
|
||||
gc.setColor(.5,.26,.26)
|
||||
gc.draw(img,scr.w*.5,scr.h*.5,t*.15,scr.rad*.0625,nil,16,16)
|
||||
end--Red rainbow
|
||||
|
||||
function BGinit.game3()
|
||||
t=0
|
||||
img=_G.IMG.gameBG1
|
||||
end
|
||||
function BGupdate.game3(dt)
|
||||
t=t+dt
|
||||
end
|
||||
function BGdraw.game3()
|
||||
gc.setColor(.4,.4,.8)
|
||||
gc.draw(img,scr.w*.5,scr.h*.5,t*.15,scr.rad*.0625,nil,16,16)
|
||||
end--Blue rainbow
|
||||
|
||||
function BGinit.game4()
|
||||
t=0
|
||||
img=_G.IMG.gameBG2
|
||||
end
|
||||
function BGupdate.game4(dt)
|
||||
t=t+dt
|
||||
end
|
||||
function BGdraw.game4()
|
||||
gc.setColor(.05,.4,.4)
|
||||
local x=t%8*-128
|
||||
::L::
|
||||
gc.draw(img,x,0,nil,8,scr.h)
|
||||
x=x+1024--image width*8
|
||||
if x<scr.w then goto L end
|
||||
end--Fast strap
|
||||
|
||||
function BGinit.game5()
|
||||
t=0
|
||||
end
|
||||
function BGupdate.game5(dt)
|
||||
t=t+dt
|
||||
end
|
||||
function BGdraw.game5()
|
||||
local t=2.5-t%20%6%2.5
|
||||
if t<.3 then gc.clear(t,t,t)
|
||||
else gc.clear(0,0,0)
|
||||
end
|
||||
end--Lightning
|
||||
|
||||
function BGinit.game6()
|
||||
t=0
|
||||
colorLib=_G.skin.libColor
|
||||
colorSet=_G.setting.skin
|
||||
miniBlock=_G.miniBlock
|
||||
end
|
||||
function BGupdate.game6(dt)
|
||||
t=t+dt
|
||||
end
|
||||
local blocks=require("parts/mino")
|
||||
local scs=require("parts/spinCenters")
|
||||
function BGdraw.game6()
|
||||
local t=1.2-t%10%3%1.2
|
||||
if t<.3 then gc.clear(t,t,t)
|
||||
else gc.clear(0,0,0)
|
||||
end
|
||||
local R=7-int(t*.5)%7
|
||||
local _=colorLib[colorSet[R]]
|
||||
gc.setColor(_[1],_[2],_[3],.1)
|
||||
gc.draw(miniBlock[R],640,360,t%3.1416*6,400,400,scs[R][0][2]-.5,#blocks[R][0]-scs[R][0][1]+.5)
|
||||
end--Fast lightning&spining tetromino
|
||||
|
||||
local matrixT={}for i=1,50 do matrixT[i]={}for j=1,50 do matrixT[i][j]=love.math.noise(i,j)+2 end end
|
||||
function BGinit.matrix()
|
||||
t=0
|
||||
end
|
||||
function BGupdate.matrix(dt)
|
||||
t=t+dt
|
||||
end
|
||||
function BGdraw.matrix()
|
||||
gc.scale(scr.k)
|
||||
gc.clear(.15,.15,.15)
|
||||
local _=ceil(scr.h/80)
|
||||
for i=1,ceil(scr.w/80)do
|
||||
for j=1,_ do
|
||||
gc.setColor(1,1,1,sin(matrixT[i][j]*t)*.1+.1)
|
||||
gc.rectangle("fill",80*i,80*j,-80,-80)
|
||||
end
|
||||
end
|
||||
gc.scale(1/scr.k)
|
||||
end
|
||||
|
||||
|
||||
function BGinit.space()
|
||||
stars={}
|
||||
for i=1,2600,5 do
|
||||
local s=0.75*2^(rnd()*1.5)
|
||||
stars[i]=s --size
|
||||
stars[i+1]=rnd(W) --x
|
||||
stars[i+2]=rnd(H) --y
|
||||
stars[i+3]=(rnd()-.5)*.01*s --vx
|
||||
stars[i+4]=(rnd()-.5)*.01*s --vy
|
||||
end--800 var
|
||||
end
|
||||
function BGresize.space(w,h)
|
||||
W,H=w+100,h+100
|
||||
end
|
||||
function BGupdate.space(dt)
|
||||
for i=1,2600,5 do
|
||||
stars[i+1]=(stars[i+1]+stars[i+3])%W
|
||||
stars[i+2]=(stars[i+2]+stars[i+4])%H
|
||||
end--star moving
|
||||
end
|
||||
|
||||
function BGdraw.space()
|
||||
gc.clear(.2,.2,.2)
|
||||
if not stars[1]then return end
|
||||
gc.translate(-50,-50)
|
||||
gc.setColor(.8,.8,.8)
|
||||
for i=1,2600,5 do
|
||||
local x,y=stars[i+1],stars[i+2]
|
||||
gc.circle("fill",x,y,stars[i])
|
||||
end
|
||||
gc.translate(50,50)
|
||||
end
|
||||
function BGdiscard.space()
|
||||
stars={}
|
||||
end
|
||||
|
||||
for k in next,BGdraw do
|
||||
if BGinit[k]then setfenv(BGinit[k], BGvars)end
|
||||
if BGresize[k]then setfenv(BGresize[k], BGvars)end
|
||||
if BGupdate[k]then setfenv(BGupdate[k], BGvars)end
|
||||
if BGdraw[k]then setfenv(BGdraw[k], BGvars)end
|
||||
if BGdiscard[k]then setfenv(BGdiscard[k], BGvars)end
|
||||
end
|
||||
|
||||
local BG={
|
||||
cur="none",
|
||||
resize=NULL,
|
||||
update=NULL,
|
||||
draw=BGdraw.none,
|
||||
}
|
||||
function BG.set(bg)
|
||||
if bg==BG.cur or not setting.bg then return end
|
||||
BG.cur=bg
|
||||
local _=BGdiscard[BG.cur]if _ then _()collectgarbage()end
|
||||
BG.resize=BGresize[bg]or NULL;BG.resize(scr.w,scr.h)
|
||||
_=BGinit[bg]if _ then _()end
|
||||
BG.update=BGupdate[bg]or NULL
|
||||
BG.draw=BGdraw[bg]
|
||||
end
|
||||
|
||||
return BG
|
||||
@@ -1,27 +1,13 @@
|
||||
local rem=table.remove
|
||||
|
||||
local BGM={}
|
||||
BGM.nowPlay=nil
|
||||
BGM.playing=nil--last loaded source
|
||||
BGM.playingID=nil--last loaded ID
|
||||
-- BGM.nowPlay=[str:playing ID]
|
||||
-- BGM.playing=[src:playing SRC]
|
||||
BGM.list={
|
||||
"blank",
|
||||
"way",
|
||||
"race",
|
||||
"newera",
|
||||
"push",
|
||||
"reason",
|
||||
"infinite",
|
||||
"cruelty",
|
||||
"final",
|
||||
"secret7th",
|
||||
"secret8th",
|
||||
"rockblock",
|
||||
"8-bit happiness",
|
||||
"shining terminal",
|
||||
"oxygen",
|
||||
"distortion",
|
||||
"end",
|
||||
"blank","way","newera","infinite","reason",
|
||||
"race","push","secret7th","secret8th",
|
||||
"rockblock","cruelty","final","8-bit happiness","end",
|
||||
"shining terminal","oxygen","distortion",
|
||||
}
|
||||
function BGM.loadOne(_)
|
||||
_,BGM.list[_]=BGM.list[_]
|
||||
@@ -37,20 +23,12 @@ end
|
||||
function BGM.play(s)
|
||||
if setting.bgm==0 or not s then return end
|
||||
if BGM.nowPlay~=s then
|
||||
if BGM.nowPlay then newTask(Event_task.bgmFadeOut,nil,BGM.nowPlay)end
|
||||
for i=#Task,1,-1 do
|
||||
local T=Task[i]
|
||||
if T.code==Event_task.bgmFadeIn then
|
||||
T.code=Event_task.bgmFadeOut
|
||||
elseif T.code==Event_task.bgmFadeOut and T.data==s then
|
||||
rem(Task,i)
|
||||
end
|
||||
end
|
||||
if s then
|
||||
BGM.playingID=s
|
||||
end
|
||||
BGM.nowPlay=s
|
||||
newTask(Event_task.bgmFadeIn,nil,s)
|
||||
if BGM.nowPlay then TASK.new(tickEvent.bgmFadeOut,nil,BGM.nowPlay)end
|
||||
TASK.changeCode(tickEvent.bgmFadeIn,tickEvent.bgmFadeOut)
|
||||
TASK.removeTask_data(s)
|
||||
|
||||
BGM.nowPlay,BGM.suspend=s
|
||||
TASK.new(tickEvent.bgmFadeIn,nil,s)
|
||||
BGM.playing=BGM.list[s]
|
||||
BGM.playing:play()
|
||||
end
|
||||
@@ -60,29 +38,22 @@ function BGM.freshVolume()
|
||||
local v=setting.bgm*.1
|
||||
if v>0 then
|
||||
BGM.playing:setVolume(v)
|
||||
if not BGM.nowPlay then
|
||||
if BGM.suspend then
|
||||
BGM.playing:play()
|
||||
BGM.nowPlay=BGM.playingID
|
||||
BGM.nowPlay,BGM.suspend=BGM.suspend
|
||||
end
|
||||
else
|
||||
BGM.playing:pause()
|
||||
BGM.playing:setVolume(0)
|
||||
BGM.nowPlay=nil
|
||||
BGM.playing:pause()
|
||||
BGM.suspend,BGM.nowPlay=BGM.nowPlay
|
||||
end
|
||||
end
|
||||
end
|
||||
function BGM.stop()
|
||||
if BGM.nowPlay then
|
||||
for i=1,#Task do
|
||||
local T=Task[i]
|
||||
if T.code==Event_task.bgmFadeIn and T.data==BGM.nowPlay then
|
||||
T.code=Event_task.bgmFadeOut
|
||||
goto L
|
||||
end
|
||||
end
|
||||
BGM.list[BGM.nowPlay]:stop()
|
||||
::L::
|
||||
BGM.nowPlay=nil
|
||||
TASK.new(tickEvent.bgmFadeOut,nil,BGM.nowPlay)
|
||||
end
|
||||
TASK.changeCode(tickEvent.bgmFadeIn,tickEvent.bgmFadeOut)
|
||||
BGM.playing,BGM.nowPlay=nil
|
||||
end
|
||||
return BGM
|
||||
@@ -33,10 +33,12 @@ if setting.lang==1 then
|
||||
"CLASSIC SEXY RUSSIAN BLOCKS",
|
||||
"戴上耳机以获得最佳体验",
|
||||
"少女祈祷中",
|
||||
"按键/点击以全力加载,跳过动画",
|
||||
"LrL,RlR LLr,RRl RRR/LLL F!!",--ZSLJTTI
|
||||
"按键/点击以强制满速加载",
|
||||
"LrL,RlR LLr,RRl RRR,LLL RfR,RRf,rFF FFF",--ZSLJTOI
|
||||
"RUR'U'R'FR2U'R'U'RUR'F'",
|
||||
"Am G F G",
|
||||
"Techmino 好玩!",
|
||||
"Techminohaowan",
|
||||
}
|
||||
elseif setting.lang==2 then
|
||||
L={
|
||||
@@ -72,10 +74,12 @@ elseif setting.lang==2 then
|
||||
"CLASSIC SEXY RUSSIAN BLOCKS",
|
||||
"戴上耳机以获得最佳体验",
|
||||
"少女祈祷中",
|
||||
"按键/点击以全力加载,跳过动画",
|
||||
"LrL,RlR LLr,RRl RRR/LLL F!!",
|
||||
"按键/点击以强制满速加载",
|
||||
"LrL,RlR LLr,RRl RRR,LLL RfR,RRf,rFF FFF",--ZSLJTOI
|
||||
"RUR'U'R'FR2U'R'U'RUR'F'",
|
||||
"Am G F G",
|
||||
"Techmino 好玩!",
|
||||
"Techminohaowan",
|
||||
}
|
||||
elseif setting.lang==3 then
|
||||
L={
|
||||
@@ -112,10 +116,11 @@ elseif setting.lang==3 then
|
||||
"CLASSIC SEXY RUSSIAN BLOCKS",
|
||||
"Headphones for better experience",
|
||||
"少女祈禱中",
|
||||
"any-key/click to skip loading animation",
|
||||
"any-key/click to load at fastest speed",
|
||||
"RUR'U'R'FR2U'R'U'RUR'F'",
|
||||
"Am G F G",
|
||||
"LrL,RlR LLr,RRl RRR/LLL F!!",
|
||||
"LrL,RlR LLr,RRl RRR,LLL RfR,RRf,rFF FFF",--ZSLJTOI
|
||||
"Techmino is so fun!",
|
||||
}
|
||||
end
|
||||
return L[math.random(#L)]
|
||||
40
parts/img.lua
Normal file
40
parts/img.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
local IMG={
|
||||
titleImage="mess/title.png",
|
||||
coloredTitleImage="mess/title_colored.png",
|
||||
dialCircle="mess/dialCircle.png",
|
||||
dialNeedle="mess/dialNeedle.png",
|
||||
badgeIcon="mess/badge.png",
|
||||
spinCenter="mess/spinCenter.png",
|
||||
ctrlSpeedLimit="mess/ctrlSpeedLimit.png",
|
||||
speedLimit="mess/speedLimit.png",
|
||||
pay1="mess/pay1.png",
|
||||
pay2="mess/pay2.png",
|
||||
|
||||
miyaCH="miya/ch.png",
|
||||
miyaF1="miya/f1.png",
|
||||
miyaF2="miya/f2.png",
|
||||
miyaF3="miya/f3.png",
|
||||
miyaF4="miya/f4.png",
|
||||
|
||||
gameBG1="BG/bg1.png",
|
||||
gameBG2="BG/bg2.png",
|
||||
}
|
||||
local list={}
|
||||
local count=0
|
||||
for k,v in next,IMG do
|
||||
count=count+1
|
||||
list[count]=k
|
||||
end
|
||||
function IMG.getCount()
|
||||
return count
|
||||
end
|
||||
function IMG.loadOne(_)
|
||||
local N=list[_]
|
||||
IMG[N]=love.graphics.newImage("/image/"..IMG[N])
|
||||
end
|
||||
function IMG.loadAll()
|
||||
for i=1,count do
|
||||
IMG.loadOne(i)
|
||||
end
|
||||
end
|
||||
return IMG
|
||||
@@ -43,7 +43,7 @@ local TRS={
|
||||
[30]={{0,0},{-1,0}, {-1,-1},{0,2}, {-1,2} },
|
||||
[12]={{0,0},{1,0}, {1,-1}, {0,2}, {1,2}, {1,1} },
|
||||
[21]={{0,0},{-1,0}, {-1,-1},{-1,1}, {0,-2}, {-1,-2},{-1,-1} },
|
||||
[32]={{0,0},{-1,0}, {-1,-1},{-1,1}, {1,0}, {0,2}, {-1,2} },
|
||||
[32]={{0,0},{-1,0}, {-1,-1},{-1,1}, {1,0}, {0,-1}, {0,2}, {-1,2} },
|
||||
[23]={{0,0},{1,0}, {1,1}, {-1,0}, {0,-2}, {1,-2} },
|
||||
[02]={{0,0},{1,0}, {-1,0}, {0,-1}, {0,1} },
|
||||
[20]={{0,0},{-1,0}, {1,0}, {0,1}, {0,-1} },
|
||||
@@ -55,7 +55,7 @@ local TRS={
|
||||
[10]={{0,0},{1,0}, {1,-1}, {0,2}, {1,2} },
|
||||
[03]={{0,0},{1,0}, {1,1}, {0,-2}, {1,-2}, {1,-1}, {0,1} },
|
||||
[30]={{0,0},{-1,0}, {-1,-1},{0,2}, {-1,2}, {0,-1}, {-1,1} },
|
||||
[12]={{0,0},{1,0}, {1,-1}, {1,1}, {-1,0}, {0,2}, {1,2} },
|
||||
[12]={{0,0},{1,0}, {1,-1}, {1,1}, {-1,0}, {0,-1}, {0,2}, {1,2} },
|
||||
[21]={{0,0},{-1,0}, {-1,1}, {1,0}, {0,-2}, {-1,-2} },
|
||||
[32]={{0,0},{-1,0}, {-1,-1},{0,2}, {-1,2}, {-1,1} },
|
||||
[23]={{0,0},{1,0}, {1,-1}, {1,1}, {0,-2}, {1,-2}, {1,-1} },
|
||||
|
||||
106
parts/modes.lua
106
parts/modes.lua
@@ -14,76 +14,76 @@ modes={
|
||||
{"solo_3", id=13, x=-700, y=-1000, size=35,shape=1,icon="solo", unlock={14,16}},
|
||||
{"solo_4", id=14, x=-900, y=-1000, size=35,shape=1,icon="solo", unlock={15}},
|
||||
{"solo_5", id=15, x=-1100, y=-1000, size=35,shape=1,icon="solo", unlock={}},
|
||||
{"techmino49_easy", id=16, x=-900, y=-1200, size=35,shape=1,icon="", unlock={17,19}},
|
||||
{"techmino49_hard", id=17, x=-900, y=-1400, size=35,shape=1,icon="", unlock={18}},
|
||||
{"techmino49_ultimate", id=18, x=-900, y=-1600, size=35,shape=1,icon="", unlock={}},
|
||||
{"techmino49_easy", id=16, x=-900, y=-1200, size=35,shape=1,icon="royale", unlock={17,19}},
|
||||
{"techmino49_hard", id=17, x=-900, y=-1400, size=35,shape=1,icon="royale", unlock={18}},
|
||||
{"techmino49_ultimate", id=18, x=-900, y=-1600, size=35,shape=1,icon="royale", unlock={}},
|
||||
|
||||
{"techmino99_easy", id=19, x=-1100, y=-1400, size=35,shape=1,icon="", unlock={20}},
|
||||
{"techmino99_hard", id=20, x=-1100, y=-1600, size=35,shape=1,icon="", unlock={21}},
|
||||
{"techmino99_ultimate", id=21, x=-1100, y=-1800, size=35,shape=1,icon="", unlock={}},
|
||||
{"techmino99_easy", id=19, x=-1100, y=-1400, size=35,shape=1,icon="royale", unlock={20}},
|
||||
{"techmino99_hard", id=20, x=-1100, y=-1600, size=35,shape=1,icon="royale", unlock={21}},
|
||||
{"techmino99_ultimate", id=21, x=-1100, y=-1800, size=35,shape=1,icon="royale", unlock={}},
|
||||
{"round_1", id=22, x=-300, y=-800, size=35,shape=1,icon="round", unlock={23}},
|
||||
{"round_2", id=23, x=-500, y=-800, size=35,shape=1,icon="round", unlock={24}},
|
||||
{"round_3", id=24, x=-700, y=-800, size=35,shape=1,icon="round", unlock={25}},
|
||||
{"round_4", id=25, x=-900, y=-800, size=35,shape=1,icon="round", unlock={26}},
|
||||
{"round_5", id=26, x=-1100, y=-800, size=35,shape=1,icon="round", unlock={}},
|
||||
|
||||
{"master_beginner", id=27, x=0, y=-1000, size=35,shape=1,icon="", unlock={28}},
|
||||
{"master_adavnce", id=28, x=0, y=-1200, size=35,shape=1,icon="", unlock={29,30}},
|
||||
{"master_final", id=29, x=0, y=-1400, size=35,shape=1,icon="", unlock={}},
|
||||
{"GM", id=30, x=150, y=-1500, size=35,shape=1,icon="", unlock={}},
|
||||
{"master_beginner", id=27, x=0, y=-1000, size=35,shape=1,icon="master", unlock={28}},
|
||||
{"master_adavnce", id=28, x=0, y=-1200, size=35,shape=1,icon="master", unlock={29,30}},
|
||||
{"master_final", id=29, x=0, y=-1400, size=40,shape=2,icon="master", unlock={}},
|
||||
{"GM", id=30, x=150, y=-1500, size=35,shape=1,icon="master", unlock={}},
|
||||
|
||||
{"blind_easy", id=31, x=150, y=-700, size=35,shape=1,icon="", unlock={32}},
|
||||
{"blind_normal", id=32, x=150, y=-800, size=35,shape=1,icon="", unlock={33}},
|
||||
{"blind_hard", id=33, x=150, y=-900, size=35,shape=1,icon="", unlock={34}},
|
||||
{"blind_lunatic", id=34, x=150, y=-1000, size=35,shape=1,icon="", unlock={35}},
|
||||
{"blind_ultimate", id=35, x=150, y=-1100, size=35,shape=1,icon="", unlock={}},
|
||||
{"blind_easy", id=31, x=150, y=-700, size=35,shape=1,icon="blind", unlock={32}},
|
||||
{"blind_normal", id=32, x=150, y=-800, size=35,shape=1,icon="blind", unlock={33}},
|
||||
{"blind_hard", id=33, x=150, y=-900, size=35,shape=1,icon="blind", unlock={34}},
|
||||
{"blind_lunatic", id=34, x=150, y=-1000, size=35,shape=1,icon="blind", unlock={35}},
|
||||
{"blind_ultimate", id=35, x=150, y=-1100, size=35,shape=1,icon="blind", unlock={}},
|
||||
|
||||
{"classic_fast", id=36, x=-300, y=-1200, size=35,shape=2,icon="classic", unlock={}},
|
||||
|
||||
{"survivor_easy", id=37, x=300, y=-600, size=35,shape=1,icon="", unlock={38}},
|
||||
{"survivor_normal", id=38, x=500, y=-600, size=35,shape=1,icon="", unlock={39,42,44,46}},
|
||||
{"survivor_hard", id=39, x=700, y=-600, size=35,shape=1,icon="", unlock={40}},
|
||||
{"survivor_lunatic", id=40, x=900, y=-600, size=35,shape=1,icon="", unlock={41}},
|
||||
{"survivor_ultimate", id=41, x=1100, y=-600, size=35,shape=1,icon="", unlock={}},
|
||||
{"attacker_hard", id=42, x=300, y=-800, size=35,shape=1,icon="", unlock={43}},
|
||||
{"attacker_ultimate", id=43, x=300, y=-1000, size=35,shape=1,icon="", unlock={}},
|
||||
{"classic_fast", id=36, x=-300, y=-1200, size=40,shape=2,icon="classic", unlock={}},
|
||||
|
||||
{"survivor_easy", id=37, x=300, y=-600, size=35,shape=1,icon="survivor",unlock={38}},
|
||||
{"survivor_normal", id=38, x=500, y=-600, size=35,shape=1,icon="survivor",unlock={39,42,44,46}},
|
||||
{"survivor_hard", id=39, x=700, y=-600, size=35,shape=1,icon="survivor",unlock={40}},
|
||||
{"survivor_lunatic", id=40, x=900, y=-600, size=35,shape=1,icon="survivor",unlock={41}},
|
||||
{"survivor_ultimate", id=41, x=1100, y=-600, size=35,shape=1,icon="survivor",unlock={}},
|
||||
{"attacker_hard", id=42, x=300, y=-800, size=35,shape=1,icon="attacker",unlock={43}},
|
||||
{"attacker_ultimate", id=43, x=300, y=-1000, size=35,shape=1,icon="attacker",unlock={}},
|
||||
|
||||
{"defender_normal", id=44, x=500, y=-800, size=35,shape=1,icon="", unlock={45}},
|
||||
{"defender_lunatic", id=45, x=500, y=-1000, size=35,shape=1,icon="", unlock={}},
|
||||
{"defender_normal", id=44, x=500, y=-800, size=35,shape=1,icon="defender",unlock={45}},
|
||||
{"defender_lunatic", id=45, x=500, y=-1000, size=35,shape=1,icon="defender",unlock={}},
|
||||
|
||||
{"dig_hard", id=46, x=700, y=-800, size=35,shape=1,icon="", unlock={47}},
|
||||
{"dig_ultimate", id=47, x=700, y=-1000, size=35,shape=1,icon="", unlock={}},
|
||||
{"dig_hard", id=46, x=700, y=-800, size=35,shape=1,icon="dig", unlock={47}},
|
||||
{"dig_ultimate", id=47, x=700, y=-1000, size=35,shape=1,icon="dig", unlock={}},
|
||||
|
||||
{"bigbang", id=48, x=400, y=-400, size=55,shape=1,icon="", unlock={49,51,56}},
|
||||
{"c4wtrain_normal", id=49, x=700, y=-400, size=35,shape=1,icon="", unlock={50}},
|
||||
{"c4wtrain_lunatic", id=50, x=900, y=-400, size=35,shape=1,icon="", unlock={}},
|
||||
{"bigbang", id=48, x=400, y=-400, size=55,shape=1,icon="bigbang", unlock={49,51,56}},
|
||||
{"c4wtrain_normal", id=49, x=700, y=-400, size=35,shape=1,icon="c4wtrain",unlock={50}},
|
||||
{"c4wtrain_lunatic", id=50, x=900, y=-400, size=35,shape=1,icon="c4wtrain",unlock={}},
|
||||
|
||||
{"pctrain_normal", id=51, x=700, y=-200, size=35,shape=1,icon="", unlock={52,53}},
|
||||
{"pctrain_lunatic", id=52, x=900, y=-200, size=35,shape=1,icon="", unlock={}},
|
||||
{"pcchallenge_normal", id=53, x=800, y=-100, size=35,shape=1,icon="", unlock={54}},
|
||||
{"pcchallenge_hard", id=54, x=1000, y=-100, size=35,shape=1,icon="", unlock={55}},
|
||||
{"pcchallenge_lunatic", id=55, x=1200, y=-100, size=35,shape=1,icon="", unlock={}},
|
||||
{"tech_normal", id=56, x=400, y=-100, size=35,shape=1,icon="", unlock={57,58}},
|
||||
{"tech_normal+", id=57, x=650, y=150, size=35,shape=1,icon="", unlock={64}},
|
||||
{"tech_hard", id=58, x=400, y=50, size=35,shape=1,icon="", unlock={59,60}},
|
||||
{"tech_hard+", id=59, x=250, y=50, size=35,shape=1,icon="", unlock={}},
|
||||
{"tech_lunatic", id=60, x=400, y=200, size=35,shape=1,icon="", unlock={61,62}},
|
||||
{"tech_lunatic+", id=61, x=250, y=200, size=35,shape=1,icon="", unlock={}},
|
||||
{"tech_ultimate", id=62, x=400, y=350, size=35,shape=1,icon="", unlock={63}},
|
||||
{"tech_ultimate+", id=63, x=250, y=350, size=35,shape=1,icon="", unlock={}},
|
||||
{"tsd_easy", id=64, x=800, y=200, size=35,shape=1,icon="", unlock={65}},
|
||||
{"tsd_hard", id=65, x=1000, y=200, size=35,shape=1,icon="", unlock={66}},
|
||||
{"tsd_ultimate", id=66, x=1200, y=200, size=35,shape=1,icon="", unlock={}},
|
||||
{"pctrain_normal", id=51, x=700, y=-200, size=35,shape=1,icon="pctrain", unlock={52,53}},
|
||||
{"pctrain_lunatic", id=52, x=900, y=-200, size=35,shape=1,icon="pctrain", unlock={}},
|
||||
{"pcchallenge_normal", id=53, x=800, y=-100, size=35,shape=1,icon="pcchallenge",unlock={54}},
|
||||
{"pcchallenge_hard", id=54, x=1000, y=-100, size=35,shape=1,icon="pcchallenge",unlock={55}},
|
||||
{"pcchallenge_lunatic", id=55, x=1200, y=-100, size=35,shape=1,icon="pcchallenge",unlock={}},
|
||||
{"tech_normal", id=56, x=400, y=-100, size=35,shape=1,icon="tech", unlock={57,58}},
|
||||
{"tech_normal+", id=57, x=650, y=150, size=35,shape=1,icon="tech", unlock={64}},
|
||||
{"tech_hard", id=58, x=400, y=50, size=35,shape=1,icon="tech", unlock={59,60}},
|
||||
{"tech_hard+", id=59, x=250, y=50, size=35,shape=1,icon="tech", unlock={}},
|
||||
{"tech_lunatic", id=60, x=400, y=200, size=35,shape=1,icon="tech", unlock={61,62}},
|
||||
{"tech_lunatic+", id=61, x=250, y=200, size=35,shape=1,icon="tech", unlock={}},
|
||||
{"tech_ultimate", id=62, x=400, y=350, size=35,shape=1,icon="tech", unlock={63}},
|
||||
{"tech_ultimate+", id=63, x=250, y=350, size=35,shape=1,icon="tech", unlock={}},
|
||||
{"tsd_easy", id=64, x=800, y=200, size=35,shape=1,icon="tsd", unlock={65}},
|
||||
{"tsd_hard", id=65, x=1000, y=200, size=35,shape=1,icon="tsd", unlock={66}},
|
||||
{"tsd_ultimate", id=66, x=1200, y=200, size=35,shape=1,icon="tsd", unlock={}},
|
||||
|
||||
{"zen", id=67, x=-900, y=-600, size=35,shape=1,icon="zen", unlock={68,69,70}},
|
||||
{"ultra", id=68, x=-1100, y=-400, size=35,shape=1,icon="", unlock={}},
|
||||
{"infinite", id=69, x=-900, y=-400, size=35,shape=1,icon="", unlock={}},
|
||||
{"infinite_dig", id=70, x=-1100, y=-600, size=35,shape=1,icon="", unlock={}},
|
||||
{"ultra", id=68, x=-1100, y=-400, size=35,shape=1,icon="ultra", unlock={}},
|
||||
{"infinite", id=69, x=-900, y=-400, size=35,shape=1,icon="infinite",unlock={}},
|
||||
{"infinite_dig", id=70, x=-1100, y=-600, size=35,shape=1,icon="infinite_dig",unlock={}},
|
||||
{"custom_clear", id=71, x=200, y=-350, size=45,shape=3,icon="custom", unlock={}},
|
||||
{"custom_puzzle", id=72, x=200, y=-200, size=45,shape=3,icon="puzzle", unlock={}},
|
||||
{"hotseat_2P", id=73, x=-300, y=200, size=45,shape=3,icon="", unlock={}},
|
||||
{"hotseat_3P", id=74, x=-450, y=200, size=45,shape=3,icon="", unlock={}},
|
||||
{"hotseat_4P", id=75, x=-600, y=200, size=45,shape=3,icon="", unlock={}},
|
||||
{"hotseat_2P", id=73, x=-300, y=200, size=45,shape=3,icon="hotseat", unlock={}},
|
||||
{"hotseat_3P", id=74, x=-450, y=200, size=45,shape=3,icon="hotseat", unlock={}},
|
||||
{"hotseat_4P", id=75, x=-600, y=200, size=45,shape=3,icon="hotseat", unlock={}},
|
||||
}
|
||||
modeRanks={}
|
||||
for i=1,#modes do
|
||||
|
||||
@@ -38,7 +38,7 @@ function SFX.play(s,v,pos)
|
||||
while S[n]:isPlaying()do
|
||||
n=n+1
|
||||
if not S[n]then
|
||||
S[n]=S[n-1]:clone()
|
||||
S[n]=S[1]:clone()
|
||||
S[n]:seek(0)
|
||||
break
|
||||
end
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
gc=love.graphics
|
||||
shader_glow=gc.newShader("shader/glow.cs")
|
||||
local gc=love.graphics
|
||||
return{
|
||||
-- glow=gc.newShader("shader/glow.cs"),
|
||||
alpha=gc.newShader("shader/alpha.cs"),
|
||||
}
|
||||
@@ -42,6 +42,7 @@ skin.libColor={
|
||||
color.darkGreen,
|
||||
}
|
||||
function skin.load()
|
||||
local _
|
||||
gc.push()
|
||||
gc.origin()
|
||||
gc.setDefaultFilter("nearest","nearest")
|
||||
@@ -70,7 +71,7 @@ function skin.load()
|
||||
gc.setLineWidth(3)
|
||||
for i=1,11 do
|
||||
puzzleMark[i]=C(30,30)
|
||||
local _=skin.libColor[i]
|
||||
_=skin.libColor[i]
|
||||
gc.setColor(_[1],_[2],_[3],.6)
|
||||
gc.rectangle("line",5,5,20,20)
|
||||
gc.rectangle("line",10,10,10,10)
|
||||
@@ -80,7 +81,7 @@ function skin.load()
|
||||
gc.setColor(skin.libColor[i])
|
||||
gc.rectangle("line",7,7,16,16)
|
||||
end
|
||||
local _=C(30,30)
|
||||
_=C(30,30)
|
||||
gc.setColor(1,1,1)
|
||||
gc.line(5,5,25,25)
|
||||
gc.line(5,25,25,5)
|
||||
@@ -97,14 +98,14 @@ function skin.prevSet()--prev skin_set
|
||||
setting.skinSet=_
|
||||
skin.change(_)
|
||||
_=list[_]
|
||||
TEXT(_,1100,100,int(300/#_)+5,"fly")
|
||||
TEXT.show(_,1100,100,int(300/#_)+5,"fly")
|
||||
end
|
||||
function skin.nextSet()--next skin_set
|
||||
local _=setting.skinSet%L+1
|
||||
setting.skinSet=_
|
||||
skin.change(_)
|
||||
_=list[_]
|
||||
TEXT(_,1100,100,int(300/#_)+5,"fly")
|
||||
TEXT.show(_,1100,100,int(300/#_)+5,"fly")
|
||||
end
|
||||
function skin.prev(i)--prev skin for [i]
|
||||
local _=setting.skin
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
local gc=love.graphics
|
||||
local sin,cos,rnd,min=math.sin,math.cos,math.random,math.min
|
||||
|
||||
local W,H,R--w,h+=100,r=real Radius
|
||||
local stars={}
|
||||
local planet={}
|
||||
|
||||
local function newPlanet()
|
||||
local a=rnd()*3.142
|
||||
local r=(H+W)*(2+rnd())*.05
|
||||
planet.r=r
|
||||
planet.x=W*.5+cos(a)*(R+r)
|
||||
planet.y=H*.5+sin(a)*(R+r)
|
||||
planet.vx=-cos(a+rnd()-.5)*.0626
|
||||
planet.vy=-sin(a+rnd()-.5)*.0626
|
||||
planet.R=.7+rnd()*.22
|
||||
planet.G=planet.R+rnd()*.16-.1
|
||||
planet.B=.7+rnd()*.2
|
||||
end
|
||||
|
||||
local space={}--LIB
|
||||
function space.resize(w,h)
|
||||
R=((w*.5)^2+(h*.5)^2)^.5
|
||||
W,H=w+100,h+100
|
||||
end
|
||||
function space.new()
|
||||
if not W then space.resize(scr.w,scr.h)end
|
||||
newPlanet()
|
||||
for i=1,2600,5 do
|
||||
local s=0.75*2^(rnd()*1.5)
|
||||
stars[i]=s --size
|
||||
stars[i+1]=rnd(W) --x
|
||||
stars[i+2]=rnd(H) --y
|
||||
stars[i+3]=(rnd()-.5)*.01*s --vx
|
||||
stars[i+4]=(rnd()-.5)*.01*s --vy
|
||||
end--800 stars
|
||||
end
|
||||
function space.update(dt)
|
||||
local x,y=planet.x,planet.y
|
||||
planet.x=planet.x+planet.vx
|
||||
planet.y=planet.y+planet.vy
|
||||
if((planet.x-W*.5)^2+(planet.y-H*.5)^2)^.5>R+planet.r then
|
||||
newPlanet()
|
||||
end
|
||||
for i=1,2600,5 do
|
||||
stars[i+1]=(stars[i+1]+stars[i+3])%W
|
||||
stars[i+2]=(stars[i+2]+stars[i+4])%H
|
||||
end--stars moving
|
||||
end
|
||||
function space.draw()
|
||||
if not stars[1]then return end
|
||||
gc.translate(-50,-50)
|
||||
gc.setLineWidth(7)
|
||||
gc.setColor(planet.R,planet.G,planet.B,.026)
|
||||
gc.circle("line",planet.x,planet.y,planet.r+1)
|
||||
gc.setColor(planet.R,.6,planet.B,.0626)
|
||||
gc.circle("fill",planet.x,planet.y,planet.r)
|
||||
gc.setColor(.9,.9,.9)
|
||||
for i=1,2600,5 do
|
||||
local x,y=stars[i+1],stars[i+2]
|
||||
gc.circle("fill",x,y,stars[i])
|
||||
end
|
||||
gc.translate(50,50)
|
||||
end
|
||||
function space.discard()
|
||||
stars={}
|
||||
planet={}
|
||||
collectgarbage()
|
||||
end
|
||||
return space
|
||||
42
parts/sysFX.lua
Normal file
42
parts/sysFX.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
local gc=love.graphics
|
||||
local setColor=gc.setColor
|
||||
local setWidth=gc.setLineWidth
|
||||
local rect=gc.rectangle
|
||||
|
||||
local fx={}
|
||||
|
||||
local FXdraw={}
|
||||
function FXdraw.ripple(S)
|
||||
setWidth(6)
|
||||
setColor(1,1,1,1-S.t)
|
||||
local r=(10*S.t)^1.2
|
||||
rect("line",S[1]-r,S[2]-r,S[3]+2*r,S[4]+2*r)
|
||||
end
|
||||
function FXdraw.shade(S)
|
||||
setColor(S[1],S[2],S[3],1-S.t)
|
||||
rect("fill",S[4],S[5],S[6],S[7],2)
|
||||
end
|
||||
|
||||
local sysFX={}
|
||||
function sysFX.update(dt)
|
||||
for i=#fx,1,-1 do
|
||||
local S=fx[i]
|
||||
S.t=S.t+dt*S.rate
|
||||
if S.t>=1 then
|
||||
for i=i,#fx do
|
||||
fx[i]=fx[i+1]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function sysFX.draw()
|
||||
for i=1,#fx do
|
||||
fx[i]:draw()
|
||||
end
|
||||
end
|
||||
--0=ripple,x,y,w,h
|
||||
--1=shade,r,g,b,x,y,w,h
|
||||
function sysFX.new(type,duration,...)
|
||||
fx[#fx+1]={draw=FXdraw[type],t=0,rate=1/duration,...}
|
||||
end
|
||||
return sysFX
|
||||
125
parts/task.lua
125
parts/task.lua
@@ -1,71 +1,68 @@
|
||||
local min=math.min
|
||||
local mini=love.window.isMinimized
|
||||
local task={}
|
||||
function task.finish(P)
|
||||
if scene.cur~="play"then return true end
|
||||
P.endCounter=P.endCounter+1
|
||||
if P.endCounter>120 then pauseGame()end
|
||||
end
|
||||
function task.lose(P)
|
||||
P.endCounter=P.endCounter+1
|
||||
if P.endCounter>80 then
|
||||
for i=1,#P.field do
|
||||
for j=1,10 do
|
||||
if P.visTime[i][j]>0 then
|
||||
P.visTime[i][j]=P.visTime[i][j]-1
|
||||
end
|
||||
end
|
||||
end
|
||||
if P.endCounter==120 then
|
||||
for _=#P.field,1,-1 do
|
||||
freeRow.discard(P.field[_])
|
||||
freeRow.discard(P.visTime[_])
|
||||
P.field[_],P.visTime[_]=nil
|
||||
end
|
||||
if #players==1 and scene=="play"then
|
||||
pauseGame()
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
function task.throwBadge(A,data)
|
||||
data[2]=data[2]-1
|
||||
if data[2]%4==0 then
|
||||
local S,R=data[1],data[1].lastRecv
|
||||
local x1,y1,x2,y2
|
||||
if S.small then
|
||||
x1,y1=S.centerX,S.centerY
|
||||
else
|
||||
x1,y1=S.x+308*S.size,S.y+450*S.size
|
||||
end
|
||||
if R.small then
|
||||
x2,y2=R.centerX,R.centerY
|
||||
else
|
||||
x2,y2=R.x+66*R.size,R.y+344*R.size
|
||||
end
|
||||
FX_badge[#FX_badge+1]={x1,y1,x2,y2,t=0}
|
||||
--generate badge object
|
||||
local rem=table.remove
|
||||
|
||||
if not A.ai and data[2]%8==0 then
|
||||
SFX.play("collect")
|
||||
local tasks={}
|
||||
|
||||
local TASK={}
|
||||
function TASK.getCount()
|
||||
return #tasks
|
||||
end
|
||||
function TASK.update()
|
||||
for i=#tasks,1,-1 do
|
||||
local T=tasks[i]
|
||||
if T.code(T.P,T.data)then
|
||||
for i=i,#tasks do
|
||||
tasks[i]=tasks[i+1]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function TASK.new(code,P,data)
|
||||
tasks[#tasks+1]={
|
||||
code=code,
|
||||
P=P,
|
||||
data=data,
|
||||
}
|
||||
end
|
||||
function TASK.changeCode(c1,c2)
|
||||
for i=#tasks,1,-1 do
|
||||
if tasks[i].code==c1 then
|
||||
tasks[i].code=c2
|
||||
end
|
||||
end
|
||||
if data[2]<=0 then return true end
|
||||
end
|
||||
function task.bgmFadeOut(_,id)
|
||||
local src=BGM.list[id]
|
||||
local v=src:getVolume()-.025*setting.bgm*.1
|
||||
src:setVolume(v>0 and v or 0)
|
||||
if v<=0 then
|
||||
src:stop()
|
||||
return true
|
||||
function TASK.removeTask_code(code)
|
||||
for i=#tasks,1,-1 do
|
||||
if tasks[i].code==code then
|
||||
rem(tasks,i)
|
||||
end
|
||||
end
|
||||
end
|
||||
function task.bgmFadeIn(_,id)
|
||||
local src=BGM.list[id]
|
||||
local v=min(src:getVolume()+.025*setting.bgm*.1,setting.bgm*.1)
|
||||
src:setVolume(v)
|
||||
if v>=setting.bgm*.1 then return true end
|
||||
function TASK.removeTask_data(data)
|
||||
for i=#tasks,1,-1 do
|
||||
if tasks[i].data==data then
|
||||
rem(tasks,i)
|
||||
end
|
||||
end
|
||||
end
|
||||
return task
|
||||
function TASK.clear(opt)
|
||||
if opt=="all"then
|
||||
local i=#tasks
|
||||
while i>0 do
|
||||
tasks[i]=nil
|
||||
i=i-1
|
||||
end
|
||||
elseif opt=="play"then
|
||||
for i=#tasks,1,-1 do
|
||||
if tasks[i].P then
|
||||
rem(tasks,i)
|
||||
end
|
||||
end
|
||||
else--Player table
|
||||
for i=#tasks,1,-1 do
|
||||
if tasks[i].P==opt then
|
||||
rem(tasks,i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return TASK
|
||||
119
parts/text.lua
Normal file
119
parts/text.lua
Normal file
@@ -0,0 +1,119 @@
|
||||
local gc=love.graphics
|
||||
local rnd=math.random
|
||||
local mStr=mStr
|
||||
local rem=table.remove
|
||||
|
||||
local textFX={}
|
||||
function textFX.appear(t)
|
||||
mStr(t.text,t.x,t.y-t.font*.7)
|
||||
end
|
||||
function textFX.sudden(t)
|
||||
gc.setColor(1,1,1,1-t.c)
|
||||
mStr(t.text,t.x,t.y-t.font*.7)
|
||||
end
|
||||
function textFX.fly(t)
|
||||
mStr(t.text,t.x+(t.c-.5)^3*300,t.y-t.font*.7)
|
||||
end
|
||||
function textFX.stretch(t)
|
||||
gc.push("transform")
|
||||
gc.translate(t.x,t.y)
|
||||
if t.c<.3 then gc.scale((.3-t.c)*1.6+1,1)end
|
||||
mStr(t.text,0,-t.font*.7)
|
||||
gc.pop()
|
||||
end
|
||||
function textFX.drive(t)
|
||||
gc.push("transform")
|
||||
gc.translate(t.x,t.y)
|
||||
if t.c<.3 then gc.shear((.3-t.c)*2,0)end
|
||||
mStr(t.text,0,-t.font*.7)
|
||||
gc.pop()
|
||||
end
|
||||
function textFX.spin(t)
|
||||
gc.push("transform")
|
||||
gc.translate(t.x,t.y)
|
||||
if t.c<.3 then
|
||||
gc.rotate((.3-t.c)^2*4)
|
||||
elseif t.c>.8 then
|
||||
gc.rotate((t.c-.8)^2*-4)
|
||||
end
|
||||
mStr(t.text,0,-t.font*.7)
|
||||
gc.pop()
|
||||
end
|
||||
function textFX.flicker(t)
|
||||
local _,_,_,T=gc.getColor()
|
||||
gc.setColor(1,1,1,T*(rnd()+.5))
|
||||
mStr(t.text,t.x,t.y-t.font*.7)
|
||||
end
|
||||
function textFX.zoomout(t)
|
||||
gc.push("transform")
|
||||
local k=t.c^.5*.1+1
|
||||
gc.translate(t.x,t.y)
|
||||
gc.scale(k,k)
|
||||
mStr(t.text,0,-t.font*.7)
|
||||
gc.pop()
|
||||
end
|
||||
function textFX.beat(t)
|
||||
gc.push("transform")
|
||||
gc.translate(t.x,t.y)
|
||||
if t.c<.3 then
|
||||
local k=1.3-t.c^2/.3
|
||||
gc.scale(k,k)
|
||||
end
|
||||
mStr(t.text,0,-t.font*.7)
|
||||
gc.pop()
|
||||
end
|
||||
function textFX.mark(t)
|
||||
local _,_,_,T=gc.getColor()
|
||||
gc.setColor(1,1,1,T*.06626)
|
||||
mStr(t.text,t.x,t.y-t.font*.7)
|
||||
end
|
||||
|
||||
local TEXT={}
|
||||
function TEXT.getText(text,x,y,font,style,spd,stop)
|
||||
return{
|
||||
c=0,
|
||||
text=text,
|
||||
x=x or 0,
|
||||
y=y or 0,
|
||||
font=font or 40,
|
||||
spd=(spd or 1)/60,
|
||||
stop=stop,
|
||||
draw=textFX[style]or error("unavailable type:"..style),
|
||||
}
|
||||
end--another version of TEXT()
|
||||
function TEXT.show(text,x,y,font,style,spd,stop)
|
||||
texts[#texts+1]={
|
||||
c=0, --timer
|
||||
text=text, --string
|
||||
x=x or 0, --x
|
||||
y=y or 0, --y
|
||||
font=font or 40, --font
|
||||
spd=(spd or 1)/60, --timing speed(1=last 1 sec)
|
||||
stop=stop, --stop time(sustained text)
|
||||
draw=textFX[style]or error("unavailable type:"..style), --draw method
|
||||
}
|
||||
end
|
||||
function TEXT.update(list)
|
||||
for i=#list,1,-1 do
|
||||
local t=list[i]
|
||||
t.c=t.c+t.spd
|
||||
if t.stop then
|
||||
if t.c>t.stop then
|
||||
t.c=t.stop
|
||||
end
|
||||
end
|
||||
if t.c>1 then
|
||||
rem(list,i)
|
||||
end
|
||||
end
|
||||
end
|
||||
function TEXT.draw(list)
|
||||
for i=1,#list do
|
||||
local t=list[i]
|
||||
local p=t.c
|
||||
gc.setColor(1,1,1,p<.2 and p*5 or p<.8 and 1 or 5-p*5)
|
||||
setFont(t.font)
|
||||
t:draw()
|
||||
end
|
||||
end
|
||||
return TEXT
|
||||
71
parts/tickEvent.lua
Normal file
71
parts/tickEvent.lua
Normal file
@@ -0,0 +1,71 @@
|
||||
local min=math.min
|
||||
local mini=love.window.isMinimized
|
||||
local tickEvent={}
|
||||
function tickEvent.finish(P)
|
||||
if SCN.cur~="play"then return true end
|
||||
P.endCounter=P.endCounter+1
|
||||
if P.endCounter>120 then pauseGame()end
|
||||
end
|
||||
function tickEvent.lose(P)
|
||||
P.endCounter=P.endCounter+1
|
||||
if P.endCounter>80 then
|
||||
for i=1,#P.field do
|
||||
for j=1,10 do
|
||||
if P.visTime[i][j]>0 then
|
||||
P.visTime[i][j]=P.visTime[i][j]-1
|
||||
end
|
||||
end
|
||||
end
|
||||
if P.endCounter==120 then
|
||||
for _=#P.field,1,-1 do
|
||||
freeRow.discard(P.field[_])
|
||||
freeRow.discard(P.visTime[_])
|
||||
P.field[_],P.visTime[_]=nil
|
||||
end
|
||||
if #players==1 and SCN.cur=="play"then
|
||||
pauseGame()
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
function tickEvent.throwBadge(A,data)
|
||||
data[2]=data[2]-1
|
||||
if data[2]%4==0 then
|
||||
local S,R=data[1],data[1].lastRecv
|
||||
local x1,y1,x2,y2
|
||||
if S.small then
|
||||
x1,y1=S.centerX,S.centerY
|
||||
else
|
||||
x1,y1=S.x+308*S.size,S.y+450*S.size
|
||||
end
|
||||
if R.small then
|
||||
x2,y2=R.centerX,R.centerY
|
||||
else
|
||||
x2,y2=R.x+66*R.size,R.y+344*R.size
|
||||
end
|
||||
FX_badge[#FX_badge+1]={x1,y1,x2,y2,t=0}
|
||||
--generate badge object
|
||||
|
||||
if not A.ai and data[2]%8==0 then
|
||||
SFX.play("collect")
|
||||
end
|
||||
end
|
||||
if data[2]<=0 then return true end
|
||||
end
|
||||
function tickEvent.bgmFadeOut(_,id)
|
||||
local src=BGM.list[id]
|
||||
local v=src:getVolume()-.025*setting.bgm*.1
|
||||
src:setVolume(v>0 and v or 0)
|
||||
if v<=0 then
|
||||
src:stop()
|
||||
return true
|
||||
end
|
||||
end
|
||||
function tickEvent.bgmFadeIn(_,id)
|
||||
local src=BGM.list[id]
|
||||
local v=min(src:getVolume()+.025*setting.bgm*.1,setting.bgm*.1)
|
||||
src:setVolume(v)
|
||||
if v>=setting.bgm*.1 then return true end
|
||||
end
|
||||
return tickEvent
|
||||
@@ -1,12 +1,15 @@
|
||||
local rnd=math.random
|
||||
local rem=table.remove
|
||||
local voiceQueue={free=0}
|
||||
local VOC={}
|
||||
|
||||
function getVoice(str)
|
||||
local function getVoice(str)
|
||||
local L=voiceBank[str]
|
||||
local n=1
|
||||
while L[n]:isPlaying()do
|
||||
n=n+1
|
||||
if not L[n]then
|
||||
L[n]=L[n-1]:clone()
|
||||
L[n]=L[1]:clone()
|
||||
L[n]:seek(0)
|
||||
break
|
||||
end
|
||||
@@ -14,7 +17,7 @@ function getVoice(str)
|
||||
return L[n]
|
||||
--load voice with string
|
||||
end
|
||||
function getFreeVoiceChannel()
|
||||
function VOC.getFreeChannel()
|
||||
local i=#voiceQueue
|
||||
for i=1,i do
|
||||
if #voiceQueue[i]==0 then return i end
|
||||
@@ -22,7 +25,44 @@ function getFreeVoiceChannel()
|
||||
voiceQueue[i+1]={s=0}
|
||||
return i+1
|
||||
end
|
||||
function VOICE(s,chn)
|
||||
function VOC.getCount()
|
||||
return #voiceQueue
|
||||
end
|
||||
function VOC.update()
|
||||
for i=#voiceQueue,1,-1 do
|
||||
local Q=voiceQueue[i]
|
||||
if Q.s==0 then--闲置轨,自动删除多余
|
||||
if i>3 then
|
||||
rem(voiceQueue,i)
|
||||
end
|
||||
elseif Q.s==1 then--等待转换
|
||||
Q[1]=getVoice(Q[1])
|
||||
Q[1]:setVolume(setting.voc*.1)
|
||||
Q[1]:play()
|
||||
Q.s=Q[2]and 2 or 4
|
||||
elseif Q.s==2 then--播放1,准备2
|
||||
if Q[1]:getDuration()-Q[1]:tell()<.08 then
|
||||
Q[2]=getVoice(Q[2])
|
||||
Q[2]:setVolume(setting.voc*.1)
|
||||
Q[2]:play()
|
||||
Q.s=3
|
||||
end
|
||||
elseif Q.s==3 then--12同时播放
|
||||
if not Q[1]:isPlaying()then
|
||||
for i=1,#Q do
|
||||
Q[i]=Q[i+1]
|
||||
end
|
||||
Q.s=Q[2]and 2 or 4
|
||||
end
|
||||
elseif Q.s==4 then--最后播放
|
||||
if not Q[1].isPlaying(Q[1])then
|
||||
Q[1]=nil
|
||||
Q.s=0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function VOC.play(s,chn)
|
||||
if setting.voc>0 then
|
||||
if chn then
|
||||
local L=voiceQueue[chn]
|
||||
@@ -31,8 +71,9 @@ function VOICE(s,chn)
|
||||
L.s=1
|
||||
--添加到queue[chn]
|
||||
else
|
||||
voiceQueue[getFreeVoiceChannel()]={s=1,voiceList[s][rnd(#voiceList[s])]}
|
||||
voiceQueue[VOC.getFreeChannel()]={s=1,voiceList[s][rnd(#voiceList[s])]}
|
||||
--自动创建空轨/播放
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return VOC
|
||||
187
parts/widget.lua
Normal file
187
parts/widget.lua
Normal file
@@ -0,0 +1,187 @@
|
||||
local gc=love.graphics
|
||||
local format=string.format
|
||||
|
||||
local button={
|
||||
type="button",
|
||||
ATV=0,--activating time(0~8)
|
||||
}
|
||||
function newButton(x,y,w,h,color,font,code,hide,N)
|
||||
local _={
|
||||
x=x-w*.5,y=y-h*.5,
|
||||
w=w,h=h,
|
||||
color=color,
|
||||
font=font,
|
||||
code=code,
|
||||
hide=hide,
|
||||
next=N,
|
||||
}for k,v in next,button do _[k]=v end return _
|
||||
end
|
||||
function button:reset()
|
||||
self.ATV=0
|
||||
end
|
||||
function button:isAbove(x,y)
|
||||
return x>self.x-self.ATV and x<self.x+self.w+2*self.ATV and y>self.y-self.ATV and y<self.y+self.h+2*self.ATV
|
||||
end
|
||||
function button:FX()
|
||||
sysFX.new("ripple",.16,self.x-self.ATV,self.y-self.ATV,self.w+2*self.ATV,self.h+2*self.ATV)
|
||||
end
|
||||
function button:update()
|
||||
if widget_sel==self then
|
||||
if self.ATV<8 then self.ATV=self.ATV+1 end
|
||||
else
|
||||
if self.ATV>0 then self.ATV=self.ATV-1 end
|
||||
end
|
||||
end
|
||||
function button:draw()
|
||||
local x,y,w,h=self.x,self.y,self.w,self.h
|
||||
local r,g,b=unpack(self.color)
|
||||
gc.setColor(.2+r*.8,.2+g*.8,.2+b*.8,.7)
|
||||
gc.rectangle("fill",x-self.ATV,y-self.ATV,w+2*self.ATV,h+2*self.ATV)
|
||||
if self.ATV>0 then
|
||||
gc.setLineWidth(4)
|
||||
gc.setColor(1,1,1,self.ATV*.125)
|
||||
gc.rectangle("line",x-self.ATV+2,y-self.ATV+2,w+2*self.ATV-4,h+2*self.ATV-4)
|
||||
end
|
||||
local t=self.text
|
||||
if t then
|
||||
if type(t)=="function"then t=t()end
|
||||
setFont(self.font)
|
||||
local y0=y+h*.5-self.font*.7
|
||||
gc.setColor(1,1,1,.3)
|
||||
gc.printf(t,x-2,y0-2,w,"center")
|
||||
gc.printf(t,x-2,y0+2,w,"center")
|
||||
gc.printf(t,x+2,y0-2,w,"center")
|
||||
gc.printf(t,x+2,y0+2,w,"center")
|
||||
gc.setColor(r*.5,g*.5,b*.5)
|
||||
gc.printf(t,x,y0,w,"center")
|
||||
end
|
||||
end
|
||||
function button:getInfo()
|
||||
print(format("x=%d,y=%d,w=%d,h=%d,font=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h,self.font))
|
||||
end
|
||||
|
||||
local switch={
|
||||
type="switch",
|
||||
ATV=0,--activating time(0~8)
|
||||
CHK=0,--check alpha(0~6)
|
||||
}
|
||||
function newSwitch(x,y,font,disp,code,hide,N)
|
||||
local _={
|
||||
x=x,y=y,font=font,
|
||||
disp=disp,
|
||||
code=code,
|
||||
hide=hide,
|
||||
next=N,
|
||||
}for k,v in next,switch do _[k]=v end return _
|
||||
end
|
||||
function switch:reset()
|
||||
self.ATV=0
|
||||
self.CHK=0
|
||||
end
|
||||
function switch:isAbove(x,y)
|
||||
return x>self.x and x<self.x+50 and y>self.y-25 and y<self.y+25
|
||||
end
|
||||
function switch:update()
|
||||
local _=self.ATV
|
||||
if widget_sel==self then if _<8 then self.ATV=_+1 end
|
||||
else if _>0 then self.ATV=_-1 end
|
||||
end
|
||||
_=self.CHK
|
||||
if self:disp()then if _<6 then self.CHK=_+1 end
|
||||
else if _>0 then self.CHK=_-1 end
|
||||
end
|
||||
end
|
||||
function switch:draw()
|
||||
local x,y=self.x,self.y-25
|
||||
if self.ATV>0 then
|
||||
gc.setColor(1,1,1,self.ATV*.08)
|
||||
gc.rectangle("fill",x,y,50,50)
|
||||
end
|
||||
if self.CHK>0 then
|
||||
gc.setColor(.9,1,.9,self.CHK/6)
|
||||
gc.setLineWidth(6)
|
||||
gc.line(x+5,y+25,x+18,y+38,x+45,y+11)
|
||||
end
|
||||
--checked
|
||||
gc.setLineWidth(4)
|
||||
gc.setColor(1,1,1,.6+self.ATV*.05)
|
||||
gc.rectangle("line",x,y,50,50)
|
||||
--frame
|
||||
local t=self.text
|
||||
if t then
|
||||
gc.setColor(1,1,1)
|
||||
setFont(self.font)
|
||||
gc.printf(t,x-412,y+20-self.font*.7,400,"right")
|
||||
end
|
||||
end
|
||||
function switch:getInfo()
|
||||
print(format("x=%d,y=%d,font=%d",self.x,self.y,self.font))
|
||||
end
|
||||
|
||||
local slider={
|
||||
type="slider",
|
||||
ATV=0,--activating time(0~8)
|
||||
pos=0,--position shown
|
||||
}
|
||||
function newSlider(x,y,w,unit,font,change,disp,code,hide,N)
|
||||
local _={
|
||||
x=x,y=y,
|
||||
w=w,unit=unit,
|
||||
font=font,
|
||||
change=change,
|
||||
disp=disp,
|
||||
code=code,
|
||||
hide=hide,
|
||||
next=N,
|
||||
}for k,v in next,slider do _[k]=v end return _
|
||||
end
|
||||
function slider:reset()
|
||||
self.ATV=0
|
||||
self.pos=0
|
||||
end
|
||||
function slider:isAbove(x,y)
|
||||
return x>self.x-10 and x<self.x+self.w+10 and y>self.y-20 and y<self.y+20
|
||||
end
|
||||
function slider:update()
|
||||
if widget_sel==self then
|
||||
if self.ATV<6 then self.ATV=self.ATV+1 end
|
||||
else
|
||||
if self.ATV>0 then self.ATV=self.ATV-1 end
|
||||
end
|
||||
if not(self.hide and self.hide())then
|
||||
self.pos=self.pos*.7+self.disp()*.3
|
||||
end
|
||||
end
|
||||
function slider:draw()
|
||||
local x,y=self.x,self.y
|
||||
gc.setColor(1,1,1,.5+self.ATV*.06)
|
||||
gc.setLineWidth(2)
|
||||
local x1,x2=x,x+self.w
|
||||
for p=0,self.unit do
|
||||
local x=x1+(x2-x1)*p/self.unit
|
||||
gc.line(x,y+7,x,y-7)
|
||||
end
|
||||
--units
|
||||
gc.setLineWidth(4)
|
||||
gc.line(x1,y,x2,y)
|
||||
--axis
|
||||
local t=self.text
|
||||
if t then
|
||||
gc.setColor(1,1,1)
|
||||
setFont(self.font)
|
||||
gc.printf(t,x-312,y-self.font*.7,300,"right")
|
||||
end
|
||||
--text
|
||||
local x,y,w,h=x1+(x2-x1)*self.pos/self.unit-10-self.ATV*.5,y-16-self.ATV,20+self.ATV,32+2*self.ATV
|
||||
gc.setColor(.8,.8,.8)
|
||||
gc.rectangle("fill",x,y,w,h)
|
||||
if self.ATV>0 then
|
||||
gc.setLineWidth(2)
|
||||
gc.setColor(1,1,1,self.ATV*.16)
|
||||
gc.rectangle("line",x+1,y+1,w-2,h-2)
|
||||
end
|
||||
--block
|
||||
end
|
||||
function slider:getInfo()
|
||||
print(format("x=%d,y=%d,w=%d",self.x,self.y,self.w))
|
||||
end
|
||||
Reference in New Issue
Block a user