diff --git a/Zframework/mathExtend.lua b/Zframework/mathExtend.lua index 91c109d2..5f3db7c3 100644 --- a/Zframework/mathExtend.lua +++ b/Zframework/mathExtend.lua @@ -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 \ No newline at end of file diff --git a/Zframework/widget.lua b/Zframework/widget.lua index b10c2c74..0de18a14 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -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() diff --git a/parts/gameFuncs.lua b/parts/gameFuncs.lua index 22ca2764..dd37bfb6 100644 --- a/parts/gameFuncs.lua +++ b/parts/gameFuncs.lua @@ -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 _0 then _=max(_-.026,0) end diff --git a/parts/netPlayer.lua b/parts/netPlayer.lua index e41264fa..8761718a 100644 --- a/parts/netPlayer.lua +++ b/parts/netPlayer.lua @@ -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 diff --git a/parts/player/draw.lua b/parts/player/draw.lua index 836f9e71..2c18209a 100644 --- a/parts/player/draw.lua +++ b/parts/player/draw.lua @@ -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) diff --git a/parts/player/player.lua b/parts/player/player.lua index b1d83f0a..404aa025 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -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 ---------------------------------------------------- ---------------------------------------------------- -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.b2b10 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 diff --git a/parts/scenes/app_cubefield.lua b/parts/scenes/app_cubefield.lua index 711810d4..29b5659e 100644 --- a/parts/scenes/app_cubefield.lua +++ b/parts/scenes/app_cubefield.lua @@ -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 diff --git a/parts/scenes/app_dtw.lua b/parts/scenes/app_dtw.lua index 1c62735a..8df7ea70 100644 --- a/parts/scenes/app_dtw.lua +++ b/parts/scenes/app_dtw.lua @@ -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 diff --git a/parts/scenes/app_tap.lua b/parts/scenes/app_tap.lua index 9fb374a8..18672284 100644 --- a/parts/scenes/app_tap.lua +++ b/parts/scenes/app_tap.lua @@ -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 diff --git a/parts/scenes/game.lua b/parts/scenes/game.lua index 1533e67d..0291e218 100644 --- a/parts/scenes/game.lua +++ b/parts/scenes/game.lua @@ -298,7 +298,7 @@ local function _update_common(dt) end --Warning check - checkWarning() + checkWarning(dt) end function scene.update(dt) trigGameRate=trigGameRate+gameRate diff --git a/parts/scenes/main.lua b/parts/scenes/main.lua index 974f1e73..84fb8dea 100644 --- a/parts/scenes/main.lua +++ b/parts/scenes/main.lua @@ -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 diff --git a/parts/scenes/net_game.lua b/parts/scenes/net_game.lua index facd71e7..e403a216 100644 --- a/parts/scenes/net_game.lua +++ b/parts/scenes/net_game.lua @@ -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 diff --git a/parts/scenes/setting_skin.lua b/parts/scenes/setting_skin.lua index 326cd8d6..a83f7f29 100644 --- a/parts/scenes/setting_skin.lua +++ b/parts/scenes/setting_skin.lua @@ -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()