大量指数接近动画改为基于时间而不是帧

This commit is contained in:
MrZ626
2021-12-22 02:19:42 +08:00
parent 20a1d2bcc1
commit a8628275a0
13 changed files with 49 additions and 39 deletions

View File

@@ -30,4 +30,8 @@ function MATH.interval(v,low,high)
end
end
function MATH.expApproach(a,b,k)
return b+(a-b)*2.718281828459045^-k
end
return MATH

View File

@@ -19,6 +19,7 @@ local sub,ins,rem=string.sub,table.insert,table.remove
local xOy=SCR.xOy
local FONT=FONT
local mStr=GC.mStr
local approach=MATH.expApproach
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}}
@@ -542,7 +543,7 @@ function slider:update(dt)
if ATV>0 then self.ATV=max(ATV-dt*30,0)end
end
if not self.hide then
self.pos=self.pos*.7+self.disp()*.3
self.pos=approach(self.pos,self.disp(),dt*26)
end
end
function slider:draw()

View File

@@ -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 int,rnd=math.floor,math.random
local approach=MATH.expApproach
local SETTING,GAME,SCR=SETTING,GAME,SCR
local PLAYERS=PLAYERS
@@ -797,7 +798,7 @@ do--function resetGameData(args)
end
do--function checkWarning()
local max=math.max
function checkWarning()
function checkWarning(dt)
local P1=PLAYERS[1]
if P1.alive then
if P1.frameRun%26==0 then
@@ -817,7 +818,7 @@ do--function checkWarning()
end
local _=GAME.warnLVL
if _<GAME.warnLVL0 then
_=_*.95+GAME.warnLVL0*.05
_=approach(_,GAME.warnLVL0,dt*6)
elseif _>0 then
_=max(_-.026,0)
end

View File

@@ -7,6 +7,7 @@ local rnd,min=math.random,math.min
local sin,cos=math.sin,math.cos
local ins,rem=table.insert,table.remove
local setFont=FONT.set
local approach=MATH.expApproach
local posLists={
--1~5
@@ -193,14 +194,15 @@ function NETPLY.mouseMove(x,y)
end
end
function NETPLY.update()
function NETPLY.update(dt)
for i=1,#PLYlist do
local p=PLYlist[i]
local t=posList[i]
p.x=p.x*.9+t.x*.1
p.y=p.y*.9+t.y*.1
p.w=p.w*.9+t.w*.1
p.h=p.h*.9+t.h*.1
local d=dt*12
p.x=approach(p.x,t.x,d)
p.y=approach(p.y,t.y,d)
p.w=approach(p.w,t.w,d)
p.h=approach(p.h,t.h,d)
end
end

View File

@@ -904,10 +904,10 @@ function draw.norm(P,repMode)
setFont(25)
local tm=STRING.time(P.stat.time)
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_setColor(.97,.97,.92)
gc_print(P.score1,20,510)
gc_print(ceil(P.score1),20,510)
gc_setColor(.85,.9,.97)
gc_print(tm,20,540)

View File

@@ -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 assert,ins,rem=assert,table.insert,table.remove
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 FREEROW,TABLE,TEXT,TASK=LINE,TABLE,TEXT,TASK
@@ -2166,7 +2167,7 @@ end
--------------------------</Tick>--------------------------
--------------------------<Event>--------------------------
local function _updateMisc(P)
local function _updateMisc(P,dt)
--Finesse combo animation
if P.finesseComboTime>0 then
P.finesseComboTime=P.finesseComboTime-1
@@ -2216,7 +2217,7 @@ local function _updateMisc(P)
end
local f=P.fieldUp
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
@@ -2225,7 +2226,7 @@ local function _updateMisc(P)
if P.stat.score-P.score1<10 then
P.score1=P.score1+1
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
@@ -2302,7 +2303,7 @@ local function _updateFX(P,dt)
end
end
end
local function update_alive(P)
local function update_alive(P,dt)
local ENV=P.gameEnv
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
--Calculate key speed
--Calculate drop speed
do
local v=0
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
if P.gameEnv.layout=='royale'then
@@ -2532,14 +2533,15 @@ local function update_alive(P)
::THROW_stop::
--B2B bar animation
if P.b2b1==P.b2b then
elseif P.b2b1<P.b2b then
P.b2b1=min(P.b2b1*.98+P.b2b*.02+.4,P.b2b)
else
P.b2b1=max(P.b2b1*.95+P.b2b*.05-.6,P.b2b)
if P.b2b1~=P.b2b then
if P.b2b1<P.b2b then
P.b2b1=min(approach(P.b2b1,P.b2b,dt*6)+.4,P.b2b)
else
P.b2b1=max(approach(P.b2b1,P.b2b,dt*12)-.6,P.b2b)
end
end
_updateMisc(P)
_updateMisc(P,dt)
--[[
P:setPosition(
640-150-(30*(P.curX+P.cur.sc[2])-15),
@@ -2590,11 +2592,11 @@ local function update_streaming(P)
eventTime=P.stream[P.streamProgress]
end
end
local function update_dead(P)
local function update_dead(P,dt)
local S=P.stat
--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
P.swappingAtkMode=min(P.swappingAtkMode+2,30)
@@ -2606,7 +2608,7 @@ local function update_dead(P)
if P.b2b1>0 then
P.b2b1=max(0,P.b2b1*.92-1)
end
_updateMisc(P)
_updateMisc(P,dt)
end
function Player:_die()
self.alive=false
@@ -2664,17 +2666,17 @@ function Player:update(dt)
20
do
update_streaming(self)
update_alive(self)
update_alive(self,dt)
end
end
else
update_alive(self)
update_alive(self,dt)
end
self.trigFrame=self.trigFrame-1
end
else
while self.trigFrame>=1 do
update_dead(self)
update_dead(self,dt)
self.trigFrame=self.trigFrame-1
end
end

View File

@@ -174,7 +174,7 @@ function scene.update(dt)
end
end
life1=life1*.7+life*.3
life1=MATH.expApproach(life1,life,dt*16)
if play then
if inv>0 then

View File

@@ -280,13 +280,13 @@ function scene.touchDown(x)
end
end
function scene.update()
function scene.update(dt)
if state==1 then
local t=TIME()
time=t-startTime
local v=0
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 arcade then

View File

@@ -31,11 +31,11 @@ function scene.keyDown(key,isRep)
end
end
function scene.update()
function scene.update(dt)
local t=TIME()
local v=0
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
maxSpeed=speed
end

View File

@@ -298,7 +298,7 @@ local function _update_common(dt)
end
--Warning check
checkWarning()
checkWarning(dt)
end
function scene.update(dt)
trigGameRate=trigGameRate+gameRate

View File

@@ -134,7 +134,7 @@ function scene.update(dt)
end
local L=scene.widgetList
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

View File

@@ -246,7 +246,7 @@ function scene.update(dt)
for p=1,#PLAYERS do PLAYERS[p]:update(dt)end
--Warning check
checkWarning()
checkWarning(dt)
--Upload stream
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
end
else
NETPLY.update()
NETPLY.update(dt)
end
if newMessageTimer>0 then
newMessageTimer=newMessageTimer-1

View File

@@ -22,9 +22,9 @@ function scene.sceneInit()
end
end
function scene.update()
function scene.update(dt)
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
function scene.draw()