From f162733f8217a4246ff73151748d0f5912d2d2cc Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 31 Aug 2020 16:52:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=BB=E5=87=BB=E7=89=B9=E6=95=88=E5=92=8C?= =?UTF-8?q?=E5=BE=BD=E7=AB=A0=E7=89=B9=E6=95=88=E5=B9=B6=E5=85=A5sysFX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/sysFX.lua | 85 +++++++++++++++++++++++++++++++++++++++++- parts/gametoolfunc.lua | 2 - parts/player.lua | 12 +----- parts/tick.lua | 2 +- 4 files changed, 86 insertions(+), 15 deletions(-) diff --git a/Zframework/sysFX.lua b/Zframework/sysFX.lua index fb302a21..8a92d724 100644 --- a/Zframework/sysFX.lua +++ b/Zframework/sysFX.lua @@ -6,6 +6,37 @@ local ins,rem=table.insert,table.remove local fx={} local FXupdate={} +function FXupdate.badge(S,dt) + S.t=S.t+dt + if S.t<.2 then + S.x,S.y=S.x1-14,S.y1-14 + elseif S.t<.8 then + local t=((S.t-.2)*1.6667) + t=(3-2*t)*t*t + S.x,S.y=S.x1*(1-t)+S.x2*t-14,S.y1*(1-t)+S.y2*t-14 + else + S.x,S.y=S.x2-14,S.y2-14 + end + return S.t>=1 +end +function FXupdate.attack(S,dt) + S.t=S.t+dt + local L=S.drag + if S.t>.8 then + S.rad=S.rad*1.05+.1 + S.x,S.y=S.x2,S.y2 + elseif S.t>.2 then + local t=(S.t-.2)*1.6667 + t=(3-2*t)*t*t + S.x,S.y=S.x1*(1-t)+S.x2*t,S.y1*(1-t)+S.y2*t + + ins(L,S.x)ins(L,S.y) + end + if #L==4+4*setting.atkFX then + rem(L,1)rem(L,1) + end +return S.t>1 +end function FXupdate.ripple(S,dt) S.t=S.t+dt*S.rate return S.t>=1 @@ -20,9 +51,36 @@ function FXupdate.shade(S,dt) end local FXdraw={} +function FXdraw.badge(S) + gc.setColor(1,1,1,S.t<.2 and S.t*.6 or S.t<.8 and 1 or(1-S.t)*.6) + gc.draw(IMG.badgeIcon,S.x,S.y) +end +function FXdraw.attack(S) + gc.setLineWidth(5) + gc.push("transform") + local t=S.t + local a=(t<.2 and t*5 or t<.8 and 1 or 5-t*5)*S.a + local L=S.drag + local len=#L + local r,g,b=S.r,S.g,S.b + local rad,crn=S.rad,S.corner + for i=1,len,2 do + gc.setColor(r,g,b,.4*a*i/len) + gc.translate(L[i],L[i+1]) + gc.rotate(t*.1) + gc.circle("fill",0,0,rad,crn) + gc.rotate(-t*.1) + gc.translate(-L[i],-L[i+1]) + end + gc.translate(S.x,S.y) + gc.rotate(t*6) + gc.setColor(r,g,b,a*.5)gc.circle("line",0,0,rad,crn) + gc.setColor(r,g,b,a)gc.circle("fill",0,0,rad,crn) + gc.pop() +end function FXdraw.ripple(S) - setWidth(2) local t=S.t + setWidth(2) setColor(1,1,1,1-t) gc.circle("line",S.x,S.y,t*(2-t)*S.r) end @@ -51,6 +109,31 @@ function sysFX.draw() end end +function sysFX.newBadge(x1,y1,x2,y2) + fx[#fx+1]={ + update=FXupdate.badge, + draw=FXdraw.badge, + t=0, + x=x1,y=y1, + x1=x1,y1=y1, + x2=x2,y2=y2, + } +end +function sysFX.newAttack(x1,y1,x2,y2,rad,corner,type,r,g,b,a) + fx[#fx+1]={ + update=FXupdate.attack, + draw=FXdraw.attack, + t=0, + x=x1,y=y1, + x1=x1,y1=y1,--Start pos + x2=x2,y2=y2,--End pos + rad=rad, + corner=corner, + type=type, + r=r,g=g,b=b,a=a, + drag={},--Afterimage coordinate list + } +end function sysFX.newRipple(duration,x,y,r) fx[#fx+1]={ update=FXupdate.ripple, diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index c91a316c..cac0a52d 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -321,8 +321,6 @@ function resetGameData() BGM.play(modeEnv.bgm) TEXT.clear() - FX_badge={} - FX_attack={} if modeEnv.royaleMode then for i=1,#players do players[i]:changeAtk(randomTarget(players[i])) diff --git a/parts/player.lua b/parts/player.lua index 714dd480..ada9c3f4 100644 --- a/parts/player.lua +++ b/parts/player.lua @@ -1130,17 +1130,7 @@ function player.createBeam(P,R,send,time,target,color,clear,spin,combo) radius=radius*.4 a=.35 end - ins(FX_attack,{ - x=x1,y=y1,--Current pos - x1=x1,y1=y1,--Start pos - x2=x2,y2=y2,--End pos - rad=radius*(setting.atkFX+3)*.12, - corner=corner, - type=type==1 and"fill"or"line", - r=r,g=g,b=b,a=a*(setting.atkFX+5)*.1, - t=0, - drag={},--Afterimage coordinate list - }) + sysFX.newAttack(x1,y1,x2,y2,radius*(setting.atkFX+3)*.12,corner,type==1 and"fill"or"line",r,g,b,a*(setting.atkFX+5)*.1) end function player.newTask(P,code,data) local L=P.tasks diff --git a/parts/tick.lua b/parts/tick.lua index 813c642e..8b7936f4 100644 --- a/parts/tick.lua +++ b/parts/tick.lua @@ -57,7 +57,7 @@ function Tick.throwBadge(data)--{ifAI,Sender,timer} end --Generate badge object - FX_badge[#FX_badge+1]={x1,y1,x2,y2,t=0} + sysFX.newBadge(x1,y1,x2,y2) if not data[1]and data[3]%8==0 then SFX.play("collect")