Change note timing
This commit is contained in:
@@ -28,6 +28,8 @@ class Game{
|
||||
this.fadeOutStarted = false
|
||||
this.currentTimingPoint = 0
|
||||
this.offsetTime = 0
|
||||
this.rules = new GameRules(this)
|
||||
|
||||
assets.songs.forEach(song => {
|
||||
if(song.id == selectedSong.folder){
|
||||
this.mainAsset = song.sound
|
||||
@@ -64,45 +66,33 @@ class Game{
|
||||
var circles = this.songData.circles
|
||||
circles.forEach(circle => {
|
||||
if(!circle.getPlayed()){
|
||||
var currentTime = this.getElapsedTime().ms
|
||||
var startingTime = circle.getMS() - this.timeForDistanceCircle
|
||||
// At circle.getMS(), the circle fits the slot
|
||||
var hitTime = circle.getMS()
|
||||
var endTime = circle.getEndTime()
|
||||
var ms = this.getElapsedTime().ms
|
||||
var type = circle.getType()
|
||||
var drumrollNotes = type === "balloon" || type === "drumroll" || type === "daiDrumroll"
|
||||
var endTime = circle.getEndTime() + (drumrollNotes ? 0 : this.rules.bad)
|
||||
|
||||
if(currentTime >= startingTime && currentTime <= endTime){
|
||||
|
||||
if(currentTime>= hitTime - 50 && currentTime < hitTime - 30){
|
||||
circle.updateStatus(0)
|
||||
}else if(currentTime >= hitTime - 30 && currentTime < hitTime){
|
||||
circle.updateStatus(230)
|
||||
}else if(currentTime >= hitTime && currentTime < endTime){
|
||||
circle.updateStatus(450)
|
||||
if(drumrollNotes && !circle.rendaPlayed){
|
||||
circle.rendaPlayed = true
|
||||
if(this.controller.selectedSong.difficulty === "easy"){
|
||||
assets.sounds["renda"].stop()
|
||||
assets.sounds["renda"].play()
|
||||
}
|
||||
if(ms >= circle.getMS()){
|
||||
if(drumrollNotes && !circle.rendaPlayed){
|
||||
circle.rendaPlayed = true
|
||||
if(this.rules.difficulty === "easy"){
|
||||
assets.sounds["renda"].stop()
|
||||
assets.sounds["renda"].play()
|
||||
}
|
||||
}
|
||||
}else if(currentTime > endTime){
|
||||
}
|
||||
if(ms > endTime){
|
||||
if(!this.controller.autoPlayEnabled){
|
||||
if(drumrollNotes){
|
||||
circle.updateStatus(-1)
|
||||
circle.played(0, false)
|
||||
circle.played(-1, false)
|
||||
this.updateCurrentCircle()
|
||||
if(this.controller.multiplayer === 1){
|
||||
p2.send("drumroll", {
|
||||
pace: (this.getElapsedTime().ms - circle.getMS()) / circle.timesHit
|
||||
pace: (ms - circle.getMS()) / circle.timesHit
|
||||
})
|
||||
}
|
||||
}else{
|
||||
circle.updateStatus(-1)
|
||||
var currentScore = 0
|
||||
circle.played(currentScore, type === "daiDon" || type === "daiKa")
|
||||
circle.played(-1, type === "daiDon" || type === "daiKa")
|
||||
this.controller.displayScore(currentScore, true)
|
||||
this.updateCurrentCircle()
|
||||
this.updateCombo(currentScore)
|
||||
@@ -152,7 +142,7 @@ class Game{
|
||||
}
|
||||
}
|
||||
checkKey(keyCodes, circle, check){
|
||||
if(circle && !circle.getPlayed() && circle.getStatus() != -1){
|
||||
if(circle && !circle.getPlayed()){
|
||||
if(!this.checkScore(circle, check)){
|
||||
return
|
||||
}
|
||||
@@ -172,18 +162,33 @@ class Game{
|
||||
var typeKa = type === "ka" || type === "daiKa"
|
||||
var typeDai = type === "daiDon" || type === "daiKa"
|
||||
|
||||
var keyTime = this.controller.getKeyTime()
|
||||
var currentTime = keysDon ? keyTime["don"] : keyTime["ka"]
|
||||
var relative = currentTime - circle.getMS()
|
||||
|
||||
if(typeDon || typeKa){
|
||||
if(-this.rules.bad >= relative || relative >= this.rules.bad){
|
||||
return true
|
||||
}
|
||||
var score = 0
|
||||
if(keysDon && typeDon || keysKa && typeKa){
|
||||
if(typeDai && !keyDai){
|
||||
if(!circle.daiFailed){
|
||||
circle.daiFailed = ms
|
||||
return false
|
||||
}else if(ms < circle.daiFailed + 2000 / 60){
|
||||
}else if(ms < circle.daiFailed + this.rules.daiLeniency){
|
||||
return false
|
||||
}
|
||||
}
|
||||
var circleStatus = circle.getStatus()
|
||||
var circleStatus = -1
|
||||
relative = Math.abs(relative)
|
||||
if(relative < this.rules.good){
|
||||
circleStatus = 450
|
||||
}else if(relative < this.rules.ok){
|
||||
circleStatus = 230
|
||||
}else if(relative < this.rules.bad){
|
||||
circleStatus = 0
|
||||
}
|
||||
if(circleStatus === 230 || circleStatus === 450){
|
||||
score = circleStatus
|
||||
}
|
||||
@@ -198,19 +203,24 @@ class Game{
|
||||
if(this.controller.multiplayer == 1){
|
||||
p2.send("note", {
|
||||
score: score,
|
||||
ms: circle.getMS() - ms,
|
||||
ms: circle.getMS() - currentTime,
|
||||
dai: typeDai ? keyDai ? 2 : 1 : 0
|
||||
})
|
||||
}
|
||||
}else if(keysDon && type == "balloon"){
|
||||
this.checkBalloon(circle)
|
||||
if(check === "daiDon" && !circle.getPlayed()){
|
||||
this.checkBalloon(circle)
|
||||
}else{
|
||||
if(circle.getMS() > currentTime || currentTime > circle.getEndTime()){
|
||||
return true
|
||||
}
|
||||
}else if((keysDon || keysKa) && (type === "drumroll" || type === "daiDrumroll")){
|
||||
this.checkDrumroll(circle)
|
||||
if(keyDai){
|
||||
if(keysDon && type === "balloon"){
|
||||
this.checkBalloon(circle)
|
||||
if(check === "daiDon" && !circle.getPlayed()){
|
||||
this.checkBalloon(circle)
|
||||
}
|
||||
}else if((keysDon || keysKa) && (type === "drumroll" || type === "daiDrumroll")){
|
||||
this.checkDrumroll(circle)
|
||||
if(keyDai){
|
||||
this.checkDrumroll(circle)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
@@ -261,7 +271,7 @@ class Game{
|
||||
var circles = this.songData.circles
|
||||
var lastCircle = circles[circles.length - 1]
|
||||
var ms = this.getElapsedTime().ms
|
||||
if(!this.fadeOutStarted && ms >= lastCircle.getEndTime() + 1900){
|
||||
if(!this.fadeOutStarted && ms >= lastCircle.getEndTime() + 2000){
|
||||
this.fadeOutStarted = ms
|
||||
}
|
||||
}
|
||||
@@ -329,17 +339,21 @@ class Game{
|
||||
}
|
||||
updateTime(){
|
||||
// Refreshed date
|
||||
this.currentDate = new Date()
|
||||
var currentDate = new Date()
|
||||
var ms = this.getElapsedTime().ms
|
||||
if(ms >= 0 && !this.started){
|
||||
this.startDate = new Date()
|
||||
this.elapsedTimeSincePause = 0
|
||||
this.setElapsedTime(this.currentDate.getTime() - this.startDate.getTime())
|
||||
this.setElapsedTime(this.getAccurateTime())
|
||||
this.started = true
|
||||
}else if(ms < 0 || ms >= 0 && this.started){
|
||||
this.setElapsedTime(this.currentDate.getTime() - this.startDate.getTime() - this.elapsedTimeSincePause)
|
||||
this.setElapsedTime(this.getAccurateTime())
|
||||
}
|
||||
}
|
||||
getAccurateTime(){
|
||||
var currentDate = new Date()
|
||||
return currentDate.getTime() - this.startDate.getTime() - this.elapsedTimeSincePause
|
||||
}
|
||||
getCircles(){
|
||||
return this.songData.circles
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user