大量指数接近动画改为基于时间而不是帧
This commit is contained in:
@@ -30,4 +30,8 @@ function MATH.interval(v,low,high)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function MATH.expApproach(a,b,k)
|
||||||
|
return b+(a-b)*2.718281828459045^-k
|
||||||
|
end
|
||||||
|
|
||||||
return MATH
|
return MATH
|
||||||
@@ -19,6 +19,7 @@ local sub,ins,rem=string.sub,table.insert,table.remove
|
|||||||
local xOy=SCR.xOy
|
local xOy=SCR.xOy
|
||||||
local FONT=FONT
|
local FONT=FONT
|
||||||
local mStr=GC.mStr
|
local mStr=GC.mStr
|
||||||
|
local approach=MATH.expApproach
|
||||||
|
|
||||||
local downArrowIcon=GC.DO{40,25,{'fPoly',0,0,20,25,40,0}}
|
local downArrowIcon=GC.DO{40,25,{'fPoly',0,0,20,25,40,0}}
|
||||||
local upArrowIcon=GC.DO{40,25,{'fPoly',0,25,20,0,40,25}}
|
local upArrowIcon=GC.DO{40,25,{'fPoly',0,25,20,0,40,25}}
|
||||||
@@ -542,7 +543,7 @@ function slider:update(dt)
|
|||||||
if ATV>0 then self.ATV=max(ATV-dt*30,0)end
|
if ATV>0 then self.ATV=max(ATV-dt*30,0)end
|
||||||
end
|
end
|
||||||
if not self.hide then
|
if not self.hide then
|
||||||
self.pos=self.pos*.7+self.disp()*.3
|
self.pos=approach(self.pos,self.disp(),dt*26)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function slider:draw()
|
function slider:draw()
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ local gc_draw,gc_rectangle,gc_line,gc_printf=gc.draw,gc.rectangle,gc.line,gc.pri
|
|||||||
|
|
||||||
local ins,rem=table.insert,table.remove
|
local ins,rem=table.insert,table.remove
|
||||||
local int,rnd=math.floor,math.random
|
local int,rnd=math.floor,math.random
|
||||||
|
local approach=MATH.expApproach
|
||||||
|
|
||||||
local SETTING,GAME,SCR=SETTING,GAME,SCR
|
local SETTING,GAME,SCR=SETTING,GAME,SCR
|
||||||
local PLAYERS=PLAYERS
|
local PLAYERS=PLAYERS
|
||||||
@@ -797,7 +798,7 @@ do--function resetGameData(args)
|
|||||||
end
|
end
|
||||||
do--function checkWarning()
|
do--function checkWarning()
|
||||||
local max=math.max
|
local max=math.max
|
||||||
function checkWarning()
|
function checkWarning(dt)
|
||||||
local P1=PLAYERS[1]
|
local P1=PLAYERS[1]
|
||||||
if P1.alive then
|
if P1.alive then
|
||||||
if P1.frameRun%26==0 then
|
if P1.frameRun%26==0 then
|
||||||
@@ -817,7 +818,7 @@ do--function checkWarning()
|
|||||||
end
|
end
|
||||||
local _=GAME.warnLVL
|
local _=GAME.warnLVL
|
||||||
if _<GAME.warnLVL0 then
|
if _<GAME.warnLVL0 then
|
||||||
_=_*.95+GAME.warnLVL0*.05
|
_=approach(_,GAME.warnLVL0,dt*6)
|
||||||
elseif _>0 then
|
elseif _>0 then
|
||||||
_=max(_-.026,0)
|
_=max(_-.026,0)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ local rnd,min=math.random,math.min
|
|||||||
local sin,cos=math.sin,math.cos
|
local sin,cos=math.sin,math.cos
|
||||||
local ins,rem=table.insert,table.remove
|
local ins,rem=table.insert,table.remove
|
||||||
local setFont=FONT.set
|
local setFont=FONT.set
|
||||||
|
local approach=MATH.expApproach
|
||||||
|
|
||||||
local posLists={
|
local posLists={
|
||||||
--1~5
|
--1~5
|
||||||
@@ -193,14 +194,15 @@ function NETPLY.mouseMove(x,y)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function NETPLY.update()
|
function NETPLY.update(dt)
|
||||||
for i=1,#PLYlist do
|
for i=1,#PLYlist do
|
||||||
local p=PLYlist[i]
|
local p=PLYlist[i]
|
||||||
local t=posList[i]
|
local t=posList[i]
|
||||||
p.x=p.x*.9+t.x*.1
|
local d=dt*12
|
||||||
p.y=p.y*.9+t.y*.1
|
p.x=approach(p.x,t.x,d)
|
||||||
p.w=p.w*.9+t.w*.1
|
p.y=approach(p.y,t.y,d)
|
||||||
p.h=p.h*.9+t.h*.1
|
p.w=approach(p.w,t.w,d)
|
||||||
|
p.h=approach(p.h,t.h,d)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -904,10 +904,10 @@ function draw.norm(P,repMode)
|
|||||||
setFont(25)
|
setFont(25)
|
||||||
local tm=STRING.time(P.stat.time)
|
local tm=STRING.time(P.stat.time)
|
||||||
gc_setColor(0,0,0,.3)
|
gc_setColor(0,0,0,.3)
|
||||||
gc_print(P.score1,18,509)
|
gc_print(ceil(P.score1),18,509)
|
||||||
gc_print(tm,18,539)
|
gc_print(tm,18,539)
|
||||||
gc_setColor(.97,.97,.92)
|
gc_setColor(.97,.97,.92)
|
||||||
gc_print(P.score1,20,510)
|
gc_print(ceil(P.score1),20,510)
|
||||||
gc_setColor(.85,.9,.97)
|
gc_setColor(.85,.9,.97)
|
||||||
gc_print(tm,20,540)
|
gc_print(tm,20,540)
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ local int,ceil,rnd=math.floor,math.ceil,math.random
|
|||||||
local max,min,abs,modf=math.max,math.min,math.abs,math.modf
|
local max,min,abs,modf=math.max,math.min,math.abs,math.modf
|
||||||
local assert,ins,rem=assert,table.insert,table.remove
|
local assert,ins,rem=assert,table.insert,table.remove
|
||||||
local resume,yield,status=coroutine.resume,coroutine.yield,coroutine.status
|
local resume,yield,status=coroutine.resume,coroutine.yield,coroutine.status
|
||||||
|
local approach=MATH.expApproach
|
||||||
|
|
||||||
local SFX,BGM,VOC,VIB,SYSFX=SFX,BGM,VOC,VIB,SYSFX
|
local SFX,BGM,VOC,VIB,SYSFX=SFX,BGM,VOC,VIB,SYSFX
|
||||||
local FREEROW,TABLE,TEXT,TASK=LINE,TABLE,TEXT,TASK
|
local FREEROW,TABLE,TEXT,TASK=LINE,TABLE,TEXT,TASK
|
||||||
@@ -2166,7 +2167,7 @@ end
|
|||||||
--------------------------</Tick>--------------------------
|
--------------------------</Tick>--------------------------
|
||||||
|
|
||||||
--------------------------<Event>--------------------------
|
--------------------------<Event>--------------------------
|
||||||
local function _updateMisc(P)
|
local function _updateMisc(P,dt)
|
||||||
--Finesse combo animation
|
--Finesse combo animation
|
||||||
if P.finesseComboTime>0 then
|
if P.finesseComboTime>0 then
|
||||||
P.finesseComboTime=P.finesseComboTime-1
|
P.finesseComboTime=P.finesseComboTime-1
|
||||||
@@ -2216,7 +2217,7 @@ local function _updateMisc(P)
|
|||||||
end
|
end
|
||||||
local f=P.fieldUp
|
local f=P.fieldUp
|
||||||
if f~=y then
|
if f~=y then
|
||||||
P.fieldUp=f>y and max(f*.95+y*.05-2,y)or min(f*.97+y*.03+1,y)
|
P.fieldUp=f>y and max(approach(f,y,dt*6)-2,y)or min(approach(f,y,dt*3)+1,y)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2225,7 +2226,7 @@ local function _updateMisc(P)
|
|||||||
if P.stat.score-P.score1<10 then
|
if P.stat.score-P.score1<10 then
|
||||||
P.score1=P.score1+1
|
P.score1=P.score1+1
|
||||||
else
|
else
|
||||||
P.score1=int(min(P.score1*.9+P.stat.score*.1+1))
|
P.score1=approach(P.score1,P.stat.score,dt*62)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2302,7 +2303,7 @@ local function _updateFX(P,dt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function update_alive(P)
|
local function update_alive(P,dt)
|
||||||
local ENV=P.gameEnv
|
local ENV=P.gameEnv
|
||||||
|
|
||||||
P.frameRun=P.frameRun+1
|
P.frameRun=P.frameRun+1
|
||||||
@@ -2332,11 +2333,11 @@ local function update_alive(P)
|
|||||||
|
|
||||||
if P.timing then P.stat.frame=P.stat.frame+1 end
|
if P.timing then P.stat.frame=P.stat.frame+1 end
|
||||||
|
|
||||||
--Calculate key speed
|
--Calculate drop speed
|
||||||
do
|
do
|
||||||
local v=0
|
local v=0
|
||||||
for i=2,10 do v=v+i*(i-1)*72/(P.frameRun-P.dropTime[i])end
|
for i=2,10 do v=v+i*(i-1)*72/(P.frameRun-P.dropTime[i])end
|
||||||
P.dropSpeed=P.dropSpeed*.99+v*.01
|
P.dropSpeed=approach(P.dropSpeed,v,dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
if P.gameEnv.layout=='royale'then
|
if P.gameEnv.layout=='royale'then
|
||||||
@@ -2532,14 +2533,15 @@ local function update_alive(P)
|
|||||||
::THROW_stop::
|
::THROW_stop::
|
||||||
|
|
||||||
--B2B bar animation
|
--B2B bar animation
|
||||||
if P.b2b1==P.b2b then
|
if P.b2b1~=P.b2b then
|
||||||
elseif P.b2b1<P.b2b then
|
if P.b2b1<P.b2b then
|
||||||
P.b2b1=min(P.b2b1*.98+P.b2b*.02+.4,P.b2b)
|
P.b2b1=min(approach(P.b2b1,P.b2b,dt*6)+.4,P.b2b)
|
||||||
else
|
else
|
||||||
P.b2b1=max(P.b2b1*.95+P.b2b*.05-.6,P.b2b)
|
P.b2b1=max(approach(P.b2b1,P.b2b,dt*12)-.6,P.b2b)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_updateMisc(P)
|
_updateMisc(P,dt)
|
||||||
--[[
|
--[[
|
||||||
P:setPosition(
|
P:setPosition(
|
||||||
640-150-(30*(P.curX+P.cur.sc[2])-15),
|
640-150-(30*(P.curX+P.cur.sc[2])-15),
|
||||||
@@ -2590,11 +2592,11 @@ local function update_streaming(P)
|
|||||||
eventTime=P.stream[P.streamProgress]
|
eventTime=P.stream[P.streamProgress]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function update_dead(P)
|
local function update_dead(P,dt)
|
||||||
local S=P.stat
|
local S=P.stat
|
||||||
|
|
||||||
--Final average speed
|
--Final average speed
|
||||||
P.dropSpeed=P.dropSpeed*.96+S.piece/S.frame*144
|
P.dropSpeed=approach(P.dropSpeed,S.piece/S.frame*3600,dt)
|
||||||
|
|
||||||
if P.gameEnv.layout=='royale'then
|
if P.gameEnv.layout=='royale'then
|
||||||
P.swappingAtkMode=min(P.swappingAtkMode+2,30)
|
P.swappingAtkMode=min(P.swappingAtkMode+2,30)
|
||||||
@@ -2606,7 +2608,7 @@ local function update_dead(P)
|
|||||||
if P.b2b1>0 then
|
if P.b2b1>0 then
|
||||||
P.b2b1=max(0,P.b2b1*.92-1)
|
P.b2b1=max(0,P.b2b1*.92-1)
|
||||||
end
|
end
|
||||||
_updateMisc(P)
|
_updateMisc(P,dt)
|
||||||
end
|
end
|
||||||
function Player:_die()
|
function Player:_die()
|
||||||
self.alive=false
|
self.alive=false
|
||||||
@@ -2664,17 +2666,17 @@ function Player:update(dt)
|
|||||||
20
|
20
|
||||||
do
|
do
|
||||||
update_streaming(self)
|
update_streaming(self)
|
||||||
update_alive(self)
|
update_alive(self,dt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
update_alive(self)
|
update_alive(self,dt)
|
||||||
end
|
end
|
||||||
self.trigFrame=self.trigFrame-1
|
self.trigFrame=self.trigFrame-1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
while self.trigFrame>=1 do
|
while self.trigFrame>=1 do
|
||||||
update_dead(self)
|
update_dead(self,dt)
|
||||||
self.trigFrame=self.trigFrame-1
|
self.trigFrame=self.trigFrame-1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ function scene.update(dt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
life1=life1*.7+life*.3
|
life1=MATH.expApproach(life1,life,dt*16)
|
||||||
|
|
||||||
if play then
|
if play then
|
||||||
if inv>0 then
|
if inv>0 then
|
||||||
|
|||||||
@@ -280,13 +280,13 @@ function scene.touchDown(x)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.update()
|
function scene.update(dt)
|
||||||
if state==1 then
|
if state==1 then
|
||||||
local t=TIME()
|
local t=TIME()
|
||||||
time=t-startTime
|
time=t-startTime
|
||||||
local v=0
|
local v=0
|
||||||
for i=2,20 do v=v+i*(i-1)*.3/(t-keyTime[i])end
|
for i=2,20 do v=v+i*(i-1)*.3/(t-keyTime[i])end
|
||||||
speed=speed*.99+v*.01
|
speed=MATH.expApproach(speed,v,dt)
|
||||||
if speed>maxSpeed then maxSpeed=speed end
|
if speed>maxSpeed then maxSpeed=speed end
|
||||||
|
|
||||||
if arcade then
|
if arcade then
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ function scene.keyDown(key,isRep)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.update()
|
function scene.update(dt)
|
||||||
local t=TIME()
|
local t=TIME()
|
||||||
local v=0
|
local v=0
|
||||||
for i=2,40 do v=v+i*(i-1)*.075/(t-keyTime[i])end
|
for i=2,40 do v=v+i*(i-1)*.075/(t-keyTime[i])end
|
||||||
speed=speed*.99+v*.01
|
speed=MATH.expApproach(speed,v,dt)
|
||||||
if speed>maxSpeed then
|
if speed>maxSpeed then
|
||||||
maxSpeed=speed
|
maxSpeed=speed
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ local function _update_common(dt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Warning check
|
--Warning check
|
||||||
checkWarning()
|
checkWarning(dt)
|
||||||
end
|
end
|
||||||
function scene.update(dt)
|
function scene.update(dt)
|
||||||
trigGameRate=trigGameRate+gameRate
|
trigGameRate=trigGameRate+gameRate
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ function scene.update(dt)
|
|||||||
end
|
end
|
||||||
local L=scene.widgetList
|
local L=scene.widgetList
|
||||||
for i=1,8 do
|
for i=1,8 do
|
||||||
L[i].x=L[i].x*.9+(widgetX0[i]-400+(WIDGET.isFocus(L[i])and(i<5 and 100 or -100)or 0))*.1
|
L[i].x=MATH.expApproach(L[i].x,(widgetX0[i]-400+(WIDGET.isFocus(L[i])and(i<5 and 100 or -100)or 0)),dt*12)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ function scene.update(dt)
|
|||||||
for p=1,#PLAYERS do PLAYERS[p]:update(dt)end
|
for p=1,#PLAYERS do PLAYERS[p]:update(dt)end
|
||||||
|
|
||||||
--Warning check
|
--Warning check
|
||||||
checkWarning()
|
checkWarning(dt)
|
||||||
|
|
||||||
--Upload stream
|
--Upload stream
|
||||||
if not NET.spectate and P1.frameRun-lastUpstreamTime>8 then
|
if not NET.spectate and P1.frameRun-lastUpstreamTime>8 then
|
||||||
@@ -265,7 +265,7 @@ function scene.update(dt)
|
|||||||
lastUpstreamTime=PLAYERS[1].alive and P1.frameRun or 1e99
|
lastUpstreamTime=PLAYERS[1].alive and P1.frameRun or 1e99
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
NETPLY.update()
|
NETPLY.update(dt)
|
||||||
end
|
end
|
||||||
if newMessageTimer>0 then
|
if newMessageTimer>0 then
|
||||||
newMessageTimer=newMessageTimer-1
|
newMessageTimer=newMessageTimer-1
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ function scene.sceneInit()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.update()
|
function scene.update(dt)
|
||||||
for i=1,7 do
|
for i=1,7 do
|
||||||
minoRot[i]=minoRot[i]*.8+minoRot0[i]*.2
|
minoRot[i]=MATH.expApproach(minoRot[i],minoRot0[i],dt*12)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function scene.draw()
|
function scene.draw()
|
||||||
|
|||||||
Reference in New Issue
Block a user