From fddb2db8c74cbfd9b39f6bfea0b4ef84205719be Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 25 Sep 2021 19:29:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=20?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=E5=B8=A7=E6=9B=B4=E6=96=B0=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=9B=B4=E6=96=B0=20=E5=BE=AE=E8=B0=83cubes?= =?UTF-8?q?=E8=83=8C=E6=99=AF=20=E5=BE=AE=E8=B0=83=E9=9F=B3=E4=B9=90?= =?UTF-8?q?=E5=AE=A4ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/task.lua | 8 ++-- parts/backgrounds/cubes.lua | 2 +- parts/scenes/game.lua | 2 +- parts/scenes/music.lua | 58 +++++++++++++-------------- parts/scenes/net_game.lua | 2 +- parts/scenes/pause.lua | 62 +++++++++++++--------------- parts/scenes/setting_control.lua | 69 +++++++++++++++++--------------- parts/scenes/stat.lua | 2 +- parts/virtualKey.lua | 5 ++- 9 files changed, 104 insertions(+), 106 deletions(-) diff --git a/Zframework/task.lua b/Zframework/task.lua index c1d6e5f4..c3a3a462 100644 --- a/Zframework/task.lua +++ b/Zframework/task.lua @@ -6,10 +6,10 @@ local TASK={} function TASK.getCount() return #tasks end -local trigTime=0 +local trigFrame=0 function TASK.update(dt) - trigTime=trigTime+dt - while trigTime>1/60 do + trigFrame=trigFrame+dt*60 + while trigFrame>=1 do for i=#tasks,1,-1 do local T=tasks[i] if status(T.thread)=='dead'then @@ -18,7 +18,7 @@ function TASK.update(dt) assert(resume(T.thread)) end end - trigTime=trigTime-1/60 + trigFrame=trigFrame-1 end end function TASK.new(code,...) diff --git a/parts/backgrounds/cubes.lua b/parts/backgrounds/cubes.lua index 1ad00108..84442a1f 100644 --- a/parts/backgrounds/cubes.lua +++ b/parts/backgrounds/cubes.lua @@ -72,7 +72,7 @@ function back.draw() gc_setColor(c[1],c[2],c[3],.2) gc_rectangle('line',S.x,S.y,S.size,S.size) gc_setColor(c[1],c[2],c[3],.3) - gc_rectangle('fill',S.x,S.y,S.size,S.size) + gc_rectangle('fill',S.x+3,S.y+3,S.size-6,S.size-6) end end function back.discard() diff --git a/parts/scenes/game.lua b/parts/scenes/game.lua index 002fb943..d30df042 100644 --- a/parts/scenes/game.lua +++ b/parts/scenes/game.lua @@ -295,7 +295,7 @@ end local function _update_common(dt) --Update control touchMoveLastFrame=false - VK.update() + VK.update(dt) --Update players for p=1,#PLAYERS do PLAYERS[p]:update(dt)end diff --git a/parts/scenes/music.lua b/parts/scenes/music.lua index e82429c0..0612e325 100644 --- a/parts/scenes/music.lua +++ b/parts/scenes/music.lua @@ -1,20 +1,22 @@ local gc=love.graphics +local gc_setColor,gc_print=gc.setColor,gc.print local sin=math.sin +local setFont=setFont local author={ blank="MrZ (old works)", - race="MrZ (old works)", - infinite="MrZ (old works)", - push="MrZ (old works)", - way="MrZ (old works)", - reason="MrZ (old works)", + ["end"]="MrZ (old works)", cruelty="MrZ (old works)", final="MrZ (old works)", - ["end"]="MrZ (old works)", + infinite="MrZ (old works)", + push="MrZ (old works)", + race="MrZ (old works)", + reason="MrZ (old works)", + way="MrZ (old works)", battle="Aether & MrZ", - empty="ERM", - ["how feeling"]="????", moonbeam="Beethoven & MrZ", + empty="ERM", + ["how feeling"]="V.A.", ["secret7th remix"]="柒栎流星", ["jazz nihilism"]="Trebor", } @@ -63,46 +65,42 @@ function scene.keyDown(key,isRep) end function scene.draw() - gc.setColor(COLOR.Z) + gc_setColor(COLOR.Z) + --Scroller + gc.setLineWidth(2) + gc.line(316,307,316,482) setFont(50) - gc.print(bgmList[selected],320,355) + gc_print(bgmList[selected],320,355) setFont(35) - if selected>1 then - gc.print(bgmList[selected-1],320,350-30) - end - if selected<#bgmList then - gc.print(bgmList[selected+1],320,350+65) - end + if selected>1 then gc_print(bgmList[selected-1],320,350-30)end + if selected<#bgmList then gc_print(bgmList[selected+1],320,350+65)end setFont(20) - if selected>2 then - gc.print(bgmList[selected-2],320,350-50) - end - if selected<#bgmList-1 then - gc.print(bgmList[selected+2],320,350+110) - end + if selected>2 then gc_print(bgmList[selected-2],320,350-50)end + if selected<#bgmList-1 then gc_print(bgmList[selected+2],320,350+110)end + --Music player gc.draw(TEXTURE.title,840,220,nil,.5,nil,580,118) if BGM.nowPlay then local t=TIME() setFont(45) - gc.setColor(sin(t*.5)*.2+.8,sin(t*.7)*.2+.8,sin(t)*.2+.8) - gc.print(BGM.nowPlay,710,508) + gc_setColor(sin(t*.5)*.2+.8,sin(t*.7)*.2+.8,sin(t)*.2+.8) + gc_print(BGM.nowPlay,710,508) setFont(35) - gc.setColor(1,sin(t*2.6)*.5+.5,sin(t*2.6)*.5+.5) - gc.print(author[BGM.nowPlay]or"MrZ",670,465) + gc_setColor(1,sin(t*2.6)*.5+.5,sin(t*2.6)*.5+.5) + gc_print(author[BGM.nowPlay]or"MrZ",670,465) local a=-t%2.3/2 if a<1 then - gc.setColor(1,1,1,a) + gc_setColor(1,1,1,a) gc.draw(TEXTURE.title_color,840,220,nil,.5+.062-.062*a,.5+.126-.126*a,580,118) end setFont(20) - gc.setColor(COLOR.Z) + gc_setColor(COLOR.Z) local cur=BGM.playing:tell() local dur=BGM.playing:getDuration() - gc.print(STRING.time_simp(cur%dur).." / "..STRING.time_simp(dur),480,626) + gc_print(STRING.time_simp(cur%dur).." / "..STRING.time_simp(dur),480,626) end end @@ -113,7 +111,7 @@ scene.widgetList={ WIDGET.newSlider{name="slide",x=480,y=600,w=400, disp=function()return BGM.playing:tell()/BGM.playing:getDuration()%1 end, show=false, - code=function(v)BGM.playing:seek(v*BGM.playing:getDuration())end, + code=function(v)BGM.seek(v*BGM.playing:getDuration())end, hideF=function()return not BGM.nowPlay end }, WIDGET.newSlider{name="bgm", x=760,y=80,w=400,disp=SETval('bgm'),code=function(v)SETTING.bgm=v BGM.freshVolume()end}, diff --git a/parts/scenes/net_game.lua b/parts/scenes/net_game.lua index 034cf501..221b462b 100644 --- a/parts/scenes/net_game.lua +++ b/parts/scenes/net_game.lua @@ -240,7 +240,7 @@ function scene.update(dt) local P1=PLAYERS[1] touchMoveLastFrame=false - VK.update() + VK.update(dt) --Update players for p=1,#PLAYERS do PLAYERS[p]:update(dt)end diff --git a/parts/scenes/pause.lua b/parts/scenes/pause.lua index bb76836f..70f2c1d7 100644 --- a/parts/scenes/pause.lua +++ b/parts/scenes/pause.lua @@ -182,12 +182,8 @@ function scene.update(dt) if not(GAME.result or GAME.replaying)then GAME.pauseTime=GAME.pauseTime+dt end - if timer1<50 then - timer1=timer1+1 - end - if timer2<25 then - timer2=timer2+1 - end + timer1=math.min(timer1+dt*60*.02,1) + timer2=math.min(timer2+dt*60*.04,1) end local hexList={1,0,.5,1.732*.5,-.5,1.732*.5} @@ -196,24 +192,22 @@ local textPos={90,131,-90,131,-200,-25,-90,-181,90,-181,200,-25} local dataPos={90,143,-90,143,-200,-13,-90,-169,90,-169,200,-13} local tasText=gc.newText(getFont(100),"TAS") function scene.draw() - local T=timer1*.02 - local T2=timer2*.04 - if T<1 or GAME.result then + if timer1<1 or GAME.result then SCN.scenes.game.draw() end --Dark BG - local _=T + local _=timer1 if GAME.result then _=_*.76 end gc.setColor(.12,.12,.12,_) gc.replaceTransform(SCR.origin) gc.rectangle('fill',0,0,SCR.w,SCR.h) gc.replaceTransform(SCR.xOy) - gc.setColor(.97,.97,.97,T) + gc.setColor(.97,.97,.97,timer1) --Result Text - mDraw(GAME.result and drawableText[GAME.result]or drawableText.pause,640,70-10*(5-timer1*.1)^1.5) + mDraw(GAME.result and drawableText[GAME.result]or drawableText.pause,640,70-10*(5-timer1*5)^1.5) --Mode Info (outside) gc.draw(drawableText.modeName,745-drawableText.modeName:getWidth(),143) @@ -224,16 +218,16 @@ function scene.draw() gc.translate(1050,5) local str=text.ranks[GAME.rank] setFont(80) - gc.setColor(0,0,0,T*.7) + gc.setColor(0,0,0,timer1*.7) gc.print(str,-5,-4,nil,1.5) local L=rankColor[GAME.rank] - gc.setColor(L[1],L[2],L[3],T) + gc.setColor(L[1],L[2],L[3],timer1) gc.print(str,0,0,nil,1.5) gc.pop() end if GAME.tasUsed then - gc.setColor(.97,.97,.97,T*.08) + gc.setColor(.97,.97,.97,timer1*.08) mDraw(tasText,870,395,.3,2.6) end @@ -246,9 +240,9 @@ function scene.draw() --Pause Info (outside) setFont(25) if GAME.pauseCount>0 then - gc.setColor(.97,.97,.97,T*.06) + gc.setColor(.97,.97,.97,timer1*.06) gc.rectangle('fill',-5,390,620,36,8) - gc.setColor(.97,.97,.97,T) + gc.setColor(.97,.97,.97,timer1) gc.rectangle('line',-5,390,620,36,8) mStr(("%s:[%d] %.2fs"):format(text.pauseCount,GAME.pauseCount,GAME.pauseTime),305,389) end @@ -256,9 +250,9 @@ function scene.draw() --Pages if page==0 then --Frame - gc.setColor(.97,.97,.97,T2*.06) + gc.setColor(.97,.97,.97,timer2*.06) gc.rectangle('fill',-5,-5,620,380,8) - gc.setColor(.97,.97,.97,T2) + gc.setColor(.97,.97,.97,timer2) gc.rectangle('line',-5,-5,620,380,8) --Game statistics @@ -269,7 +263,7 @@ function scene.draw() --Stats _=form setFont(30) - gc.setColor(.97,.97,.97,T2) + gc.setColor(.97,.97,.97,timer2) for i=1,10 do gc.print(text.pauseStat[i],5,43*(i-1)+2) gc.printf(_[i],210,43*(i-1)+2,500,'right') @@ -279,12 +273,12 @@ function scene.draw() if rank then setFont(40) local c=fnsRankColor[rank] - gc.setColor(c[1],c[2],c[3],T2) + gc.setColor(c[1],c[2],c[3],timer2) gc.print(rank,405,383) if trophy then setFont(30) - gc.setColor(trophyColor[1],trophyColor[2],trophyColor[3],T2*2-1) - gc.printf(trophy,95-120*(1-T2^.5),390,300,'right') + gc.setColor(trophyColor[1],trophyColor[2],trophyColor[3],timer2*2-1) + gc.printf(trophy,95-120*(1-timer2^.5),390,300,'right') end end gc.pop() @@ -296,15 +290,15 @@ function scene.draw() --Polygon gc.push('transform') - gc.scale((3-2*T2)*T2) - gc.setColor(.97,.97,.97,T2*(.5+.3*sin(TIME()*6.26))) + gc.scale((3-2*timer2)*timer2) + gc.setColor(.97,.97,.97,timer2*(.5+.3*sin(TIME()*6.26))) GC.regularPolygon('line',0,0,120,6,8) - gc.setColor(chartColor[1],chartColor[2],chartColor[3],T2*.626) + gc.setColor(chartColor[1],chartColor[2],chartColor[3],timer2*.626) for i=1,9,2 do gc.polygon('fill',0,0,val[i],val[i+1],val[i+2],val[i+3]) end gc.polygon('fill',0,0,val[11],val[12],val[1],val[2]) - gc.setColor(.97,.97,.97,T2) + gc.setColor(.97,.97,.97,timer2) for i=1,9,2 do gc.line(val[i],val[i+1],val[i+2],val[i+3]) end @@ -315,11 +309,11 @@ function scene.draw() local C _=TIME()%6.2832 if _>3.142 then - gc.setColor(.97,.97,.97,-T2*sin(_)) + gc.setColor(.97,.97,.97,-timer2*sin(_)) setFont(35) C,_=text.radar,textPos else - gc.setColor(.97,.97,.97,T2*sin(_)) + gc.setColor(.97,.97,.97,timer2*sin(_)) setFont(20) C,_=radar,dataPos end @@ -338,21 +332,21 @@ function scene.draw() if #GAME.mod>0 then gc.setLineWidth(2) if scoreValid()then - gc.setColor(.7,.7,.7,T) + gc.setColor(.7,.7,.7,timer1) gc.rectangle('line',-5,-5,500,150,8) - gc.setColor(.7,.7,.7,T*.05) + gc.setColor(.7,.7,.7,timer1*.05) gc.rectangle('fill',-5,-5,500,150,8) else - gc.setColor(.8,0,0,T) + gc.setColor(.8,0,0,timer1) gc.rectangle('line',-5,-5,500,150,8) - gc.setColor(1,0,0,T*.05) + gc.setColor(1,0,0,timer1*.05) gc.rectangle('fill',-5,-5,500,150,8) end setFont(35) for _,M in next,MODOPT do if M.sel>0 then _=M.color - gc.setColor(_[1],_[2],_[3],T) + gc.setColor(_[1],_[2],_[3],timer1) mStr(M.id,35+M.no%8*60,math.floor(M.no/8)*45) end end diff --git a/parts/scenes/setting_control.lua b/parts/scenes/setting_control.lua index 94ac03ce..40758893 100644 --- a/parts/scenes/setting_control.lua +++ b/parts/scenes/setting_control.lua @@ -11,41 +11,46 @@ function scene.sceneInit() BG.set('bg1') end -function scene.update() - if wait>0 then - wait=wait-1 - if wait==0 then - pos=pos+(das==0 and 2 or 1)*dir - else - return - end - end - if das>0 then - das=das-1 - if das==0 then - if arr==0 then - pos=pos+7*dir - das=SETTING.das+1 - arr=SETTING.arr - dir=-dir - wait=26 +local trigFrame=0 +function scene.update(dt) + trigFrame=trigFrame+dt*60 + while trigFrame>=1 do + trigFrame=trigFrame-1 + if wait>0 then + wait=wait-1 + if wait==0 then + pos=pos+(das==0 and 2 or 1)*dir else - pos=pos+dir + return end end - else - arr=arr-1 - if arr==0 then - pos=pos+dir - arr=SETTING.arr - elseif arr==-1 then - pos=dir>0 and 8 or 0 - arr=SETTING.arr - end - if pos%8==0 then - dir=-dir - wait=26 - das=SETTING.das + if das>0 then + das=das-1 + if das==0 then + if arr==0 then + pos=pos+7*dir + das=SETTING.das+1 + arr=SETTING.arr + dir=-dir + wait=26 + else + pos=pos+dir + end + end + else + arr=arr-1 + if arr==0 then + pos=pos+dir + arr=SETTING.arr + elseif arr==-1 then + pos=dir>0 and 8 or 0 + arr=SETTING.arr + end + if pos%8==0 then + dir=-dir + wait=26 + das=SETTING.das + end end end end diff --git a/parts/scenes/stat.lua b/parts/scenes/stat.lua index ae86f96f..60f62504 100644 --- a/parts/scenes/stat.lua +++ b/parts/scenes/stat.lua @@ -98,7 +98,7 @@ function scene.draw() local R=int(r)%7+1 gc_setColor(1,1,1,1-abs(r%1*2-1)) gc_draw(TEXTURE.miniBlock[R],680,50,t*10%6.2832,15,15,DSCP[R][0][2]+.5,#BLOCKS[R][0]-DSCP[R][0][1]-.5) - gc_draw(TEXTURE.miniBlock[R],680,300,0,15,15,DSCP[R][0][2]+.5,#BLOCKS[R][0]-DSCP[R][0][1]-.5) + mDraw(TEXTURE.miniBlock[R],680,300,0,15,15) end scene.widgetList={ diff --git a/parts/virtualKey.lua b/parts/virtualKey.lua index bc58b273..9cb52fe1 100644 --- a/parts/virtualKey.lua +++ b/parts/virtualKey.lua @@ -1,6 +1,7 @@ local gc=love.graphics local gc_draw,gc_setColor,gc_setLineWidth=gc.draw,gc.setColor,gc.setLineWidth +local max=math.max local next=next local SETTING,TIME=SETTING,TIME @@ -212,11 +213,11 @@ function VK.changeSet(id) end end -function VK.update() +function VK.update(dt) if SETTING.VKSwitch then for _,B in next,keys do if B.pressTime>0 then - B.pressTime=B.pressTime-1 + B.pressTime=max(B.pressTime-dt*60,0) end end end