Added song select music, more keys

This commit is contained in:
LoveEevee 2018-09-27 00:12:50 +03:00
parent f72c09f4a6
commit b053dffec1
5 changed files with 48 additions and 19 deletions

View File

@ -91,6 +91,7 @@ var assets = {
"renda.ogg" "renda.ogg"
], ],
"audioMusic": [ "audioMusic": [
"bgm_songsel.ogg",
"bgm_result.ogg", "bgm_result.ogg",
"bgm_setsume.ogg" "bgm_setsume.ogg"
], ],

View File

@ -351,8 +351,12 @@ class Game{
} }
} }
getAccurateTime(){ getAccurateTime(){
var currentDate = new Date() if(this.isPaused()){
return currentDate.getTime() - this.startDate.getTime() - this.elapsedTimeSincePause return this.getElapsedTime().ms
}else{
var currentDate = new Date()
return currentDate.getTime() - this.startDate.getTime() - this.elapsedTimeSincePause
}
} }
getCircles(){ getCircles(){
return this.songData.circles return this.songData.circles

View File

@ -91,7 +91,7 @@ class Keyboard{
var ms = this.game.getAccurateTime() var ms = this.game.getAccurateTime()
this.gamepadMenu.play((pressed, keyCode) => { this.gamepadMenu.play((pressed, keyCode) => {
if(pressed){ if(pressed){
if(this.game.isPaused()){ if(paused){
if(keyCode === "cancel"){ if(keyCode === "cancel"){
return setTimeout(() => { return setTimeout(() => {
this.controller.togglePauseMenu() this.controller.togglePauseMenu()
@ -110,17 +110,30 @@ class Keyboard{
this.controller.togglePauseMenu() this.controller.togglePauseMenu()
}) })
if(this.game.isPaused()){ if(this.game.isPaused()){
this.checkKey(this.kbd["previous"], "menu", () => { var moveMenuMinus = () => {
moveMenu = -1 moveMenu = -1
}) }
this.checkKey(this.kbd["next"], "menu", () => { var moveMenuPlus = () => {
moveMenu = 1 moveMenu = 1
}) }
this.checkKey(this.kbd["confirm"], "menu", () => { var moveMenuConfirm = () => {
setTimeout(() => { setTimeout(() => {
document.getElementsByClassName("selected")[0].click() var selected = document.getElementsByClassName("selected")[0]
if(selected){
selected.click()
}
}, 200) }, 200)
}) for(var key in this.keyTime){
this.keyTime[key] = null
}
}
this.checkKey(this.kbd["previous"], "menu", moveMenuMinus)
this.checkKey(this.kbd["ka_l"], "menu", moveMenuMinus)
this.checkKey(this.kbd["next"], "menu", moveMenuPlus)
this.checkKey(this.kbd["ka_r"], "menu", moveMenuPlus)
this.checkKey(this.kbd["confirm"], "menu", moveMenuConfirm)
this.checkKey(this.kbd["don_l"], "menu", moveMenuConfirm)
this.checkKey(this.kbd["don_r"], "menu", moveMenuConfirm)
} }
if(moveMenu){ if(moveMenu){
assets.sounds["ka"].play() assets.sounds["ka"].play()

View File

@ -116,11 +116,11 @@ class Scoresheet{
code = event.keyCode code = event.keyCode
} }
var selected = this.elem("selected", this.scoresheet) var selected = this.elem("selected", this.scoresheet)
if(code == 13){ if(code == 13 || code == 32 || code == 86 || code == 66){
// Enter // Enter, Space, V, B
selected.click() selected.click()
}else if(code == 37 || code == 39){ }else if(code == 37 || code == 39 || code == 67 || code == 78){
// Left, Right // Left, Right, C, N
selected.classList.remove("selected") selected.classList.remove("selected")
var next = selected.nextElementSibling var next = selected.nextElementSibling
if(!next){ if(!next){

View File

@ -177,7 +177,9 @@ class SongSelect{
this.selectedSong = 0 this.selectedSong = 0
this.selectedDiff = 0 this.selectedDiff = 0
if(fromTutorial){ assets.sounds["bgm_songsel"].playLoop(0.1, false, 0, 1.442, 3.506)
if(fromTutorial || !"selectedSong" in localStorage){
this.selectedSong = this.songs.findIndex(song => song.action === "tutorial") this.selectedSong = this.songs.findIndex(song => song.action === "tutorial")
}else{ }else{
if("selectedSong" in localStorage){ if("selectedSong" in localStorage){
@ -636,8 +638,8 @@ class SongSelect{
if(this.previewing !== null){ if(this.previewing !== null){
this.endPreview() this.endPreview()
} }
}else if(screen !== "title"){ }else if(screen !== "title" && ms > this.state.moveMS + 100){
if(this.previewing !== this.selectedSong){ if(this.previewing !== this.selectedSong && "id" in this.songs[this.selectedSong]){
this.startPreview() this.startPreview()
} }
} }
@ -1478,7 +1480,7 @@ class SongSelect{
var currentSong = this.songs[this.selectedSong] var currentSong = this.songs[this.selectedSong]
var id = currentSong.id var id = currentSong.id
var prvTime = currentSong.preview var prvTime = currentSong.preview
this.endPreview() this.endPreview(true)
if("id" in currentSong){ if("id" in currentSong){
var startLoad = this.getMS() var startLoad = this.getMS()
@ -1508,13 +1510,17 @@ class SongSelect{
} }
} }
previewLoaded(startLoad, prvtime){ previewLoaded(startLoad, prvtime){
snd.musicGain.fadeOut(0.4)
var endLoad = this.getMS() var endLoad = this.getMS()
var difference = endLoad - startLoad var difference = endLoad - startLoad
var minDelay = 300 var minDelay = 300
var delay = minDelay - Math.min(minDelay, difference) var delay = minDelay - Math.min(minDelay, difference)
this.preview.playLoop(delay / 1000, false, prvtime / 1000) this.preview.playLoop(delay / 1000, false, prvtime / 1000)
} }
endPreview() { endPreview(noFadeIn){
if(!noFadeIn){
snd.musicGain.fadeIn(0.4)
}
this.previewId++ this.previewId++
this.previewing = null this.previewing = null
if(this.preview){ if(this.preview){
@ -1559,6 +1565,11 @@ class SongSelect{
} }
clean(){ clean(){
assets.sounds["bgm_songsel"].stop()
snd.musicGain.fadeIn()
setTimeout(() => {
snd.musicGain.fadeIn()
}, 500)
this.redrawRunning = false this.redrawRunning = false
this.endPreview() this.endPreview()
pageEvents.keyRemove(this, "all") pageEvents.keyRemove(this, "all")