Skip to content

Commit

Permalink
不同的判定音效略有不同
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed Jan 4, 2022
1 parent 0e9e0c8 commit 4cfe733
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 25 deletions.
11 changes: 11 additions & 0 deletions parts/gameFuncs.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local gc=love.graphics
local sin=math.sin
local abs=math.abs

--System
do--function tryBack()
Expand Down Expand Up @@ -139,6 +140,16 @@ function loadBeatmap(path)
return false,res
end
end
function getHitLV(div)
div=abs(div)
return
div<=hitLVOffsets[5]and 5 or
div<=hitLVOffsets[4]and 4 or
div<=hitLVOffsets[3]and 3 or
div<=hitLVOffsets[2]and 2 or
div<=hitLVOffsets[1]and 1 or
0
end



Expand Down
16 changes: 3 additions & 13 deletions parts/scenes/game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,7 @@ local hitAccList=hitAccList
local hitLVOffsets=hitLVOffsets
local chainColors=chainColors
local trackNames=trackNames

local function _getHitLV(div)
div=abs(div)
return
div<=hitLVOffsets[5]and 5 or
div<=hitLVOffsets[4]and 4 or
div<=hitLVOffsets[3]and 3 or
div<=hitLVOffsets[2]and 2 or
div<=hitLVOffsets[1]and 1 or
0
end
local getHitLV=getHitLV
local function _showVolMes(v)
needSaveSetting=true
MES.new('info',('$1%'):repD(('%d'):format(v*100)),0)
Expand Down Expand Up @@ -164,7 +154,7 @@ end
local function _trigNote(deviateTime,noTailHold)
hitTextTime=TIME()
fullAcc=fullAcc+100
hitLV=_getHitLV(deviateTime)
hitLV=getHitLV(deviateTime)
if hitLV>0 and noTailHold then hitLV=5 end
bestChain=min(bestChain,hitLV)
hits[hitLV]=hits[hitLV]+1
Expand Down Expand Up @@ -463,7 +453,7 @@ function scene.draw()

--Draw deviate times
for i=1,#hitOffests do
local c=hitColors[_getHitLV(hitOffests[i])]
local c=hitColors[getHitLV(hitOffests[i])]
gc_setColor(c[1],c[2],c[3],.4)
gc_rectangle('fill',640+hitOffests[i]*688-1,350-8,3,20)
end
Expand Down
46 changes: 34 additions & 12 deletions parts/track.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ local gc_setColor=gc.setColor
local gc_rectangle=gc.rectangle

local max,min=math.max,math.min
local rnd=math.random
local rem=table.remove
local interval=MATH.interval

Expand Down Expand Up @@ -156,6 +155,13 @@ function Track:pollNote(mode)
end
end

local holdHeadSFX={
'hold4',
'hold3',
'hold2',
'hold1',
'hold1',
}
function Track:press()
--Animation
self.pressed=true
Expand All @@ -164,36 +170,52 @@ function Track:press()
--Check first note
local i,note=self:pollNote('note')
if note and self.time>note.time-note.trigTime then
local deviateTime=self.time-note.time
local hitLV=getHitLV(deviateTime)
local _1,_2,_3
if hitLV>0 then
_1,_2,_3=note:getAlpha(1),self.state.x/420,-(math.abs(hitLV-4.5)-.5)
end
if note.type=='tap'then--Press tap note
SFX.play('hit_tap',.4+.6*note:getAlpha(1),self.state.x/420)
rem(self.notes,i)
return self.time-note.time
if _1 then
SFX.play('hit_tap',.4+.6*_1,_2,_3)
end
elseif note.type=='hold'then--Press hold note
if note.head then
note.head=false
local _1,_2=note:getAlpha(1),self.state.x/420
SFX.play('hit_tap',.4+.5*_1,_2)
SFX.play('hold'..rnd(4),.4+.6*_1,_2)
return self.time-note.time
if not note.head then return end
note.head=false
if _1 then
SFX.play('hit_tap',.4+.5*_1,_2,_3)
SFX.play(holdHeadSFX[hitLV],.4+.6*_1,_2)
end
end
return deviateTime
end
end

local holdTailSFX={
'hit8',
'hit7',
'hit6',
'hit5',
'hit5',
}
function Track:release()
self.pressed=false
self.lastReleaseTime=self.time
local i,note=self:pollNote('hold')
if note and note.type=='hold'and not note.head then--Release hold note
local deviateTime=note.etime-self.time
local hitLV=getHitLV(deviateTime)
if self.time>note.etime-note.trigTime then
if note.tail then
SFX.play('hit'..rnd(7,8),.4+.6*note:getAlpha(1),self.state.x/420)
if note.tail and hitLV>0 then
SFX.play(holdTailSFX[hitLV],.4+.6*note:getAlpha(1),self.state.x/420)
end
rem(self.notes,i)
else
note.active=false
end
return note.etime-self.time,not note.tail
return deviateTime,not note.tail
end
end

Expand Down

0 comments on commit 4cfe733

Please sign in to comment.