Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Taiko Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Taiko Web
Commits
869857d3
Commit
869857d3
authored
Oct 07, 2018
by
LoveEevee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fallback to wav if ogg is not supported, fix circles animation
parent
b454059c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
76 deletions
+85
-76
public/src/js/assets.js
public/src/js/assets.js
+1
-0
public/src/js/circle.js
public/src/js/circle.js
+2
-7
public/src/js/game.js
public/src/js/game.js
+3
-2
public/src/js/loader.js
public/src/js/loader.js
+68
-57
public/src/js/view.js
public/src/js/view.js
+11
-10
No files found.
public/src/js/assets.js
View file @
869857d3
...
@@ -112,6 +112,7 @@ var assets = {
...
@@ -112,6 +112,7 @@ var assets = {
"
bgm_result.ogg
"
,
"
bgm_result.ogg
"
,
"
bgm_setsume.ogg
"
"
bgm_setsume.ogg
"
],
],
"
audioOgg
"
:
"
note_ka.ogg
"
,
"
fonts
"
:
[
"
fonts
"
:
[
"
Kozuka
"
,
"
Kozuka
"
,
"
TnT
"
"
TnT
"
...
...
public/src/js/circle.js
View file @
869857d3
...
@@ -31,11 +31,9 @@ class Circle{
...
@@ -31,11 +31,9 @@ class Circle{
getLastFrame
(){
getLastFrame
(){
return
this
.
lastFrame
return
this
.
lastFrame
}
}
incFrame
(){
animate
(
ms
){
this
.
lastFrame
+=
20
}
animate
(){
this
.
animating
=
true
this
.
animating
=
true
this
.
animT
=
ms
}
}
isAnimated
(){
isAnimated
(){
return
this
.
animating
return
this
.
animating
...
@@ -43,9 +41,6 @@ class Circle{
...
@@ -43,9 +41,6 @@ class Circle{
getAnimT
(){
getAnimT
(){
return
this
.
animT
return
this
.
animT
}
}
incAnimT
(){
this
.
animT
+=
0.05
}
getPlayed
(){
getPlayed
(){
return
this
.
isPlayed
return
this
.
isPlayed
}
}
...
...
public/src/js/game.js
View file @
869857d3
...
@@ -241,6 +241,7 @@ class Game{
...
@@ -241,6 +241,7 @@ class Game{
this
.
globalScore
.
points
+=
score
this
.
globalScore
.
points
+=
score
}
}
checkDrumroll
(
circle
){
checkDrumroll
(
circle
){
var
ms
=
this
.
elapsedTime
var
dai
=
circle
.
getType
()
===
"
daiDrumroll
"
var
dai
=
circle
.
getType
()
===
"
daiDrumroll
"
var
score
=
100
var
score
=
100
circle
.
hit
()
circle
.
hit
()
...
@@ -252,14 +253,14 @@ class Game{
...
@@ -252,14 +253,14 @@ class Game{
}
}
var
circleAnim
=
new
Circle
({
var
circleAnim
=
new
Circle
({
id
:
0
,
id
:
0
,
start
:
this
.
elapsedTime
,
start
:
ms
,
type
:
sound
,
type
:
sound
,
txt
:
""
,
txt
:
""
,
speed
:
circle
.
speed
,
speed
:
circle
.
speed
,
gogoTime
:
circle
.
gogoTime
gogoTime
:
circle
.
gogoTime
})
})
circleAnim
.
played
(
score
,
dai
)
circleAnim
.
played
(
score
,
dai
)
circleAnim
.
animate
()
circleAnim
.
animate
(
ms
)
this
.
controller
.
view
.
drumroll
.
push
(
circleAnim
)
this
.
controller
.
view
.
drumroll
.
push
(
circleAnim
)
this
.
globalScore
.
drumroll
++
this
.
globalScore
.
drumroll
++
this
.
globalScore
.
points
+=
score
*
(
dai
?
2
:
1
)
this
.
globalScore
.
points
+=
score
*
(
dai
?
2
:
1
)
...
...
public/src/js/loader.js
View file @
869857d3
...
@@ -11,29 +11,7 @@ class Loader{
...
@@ -11,29 +11,7 @@ class Loader{
this
.
screen
.
innerHTML
=
page
this
.
screen
.
innerHTML
=
page
this
.
loaderPercentage
=
document
.
querySelector
(
"
#loader .percentage
"
)
this
.
loaderPercentage
=
document
.
querySelector
(
"
#loader .percentage
"
)
this
.
loaderProgress
=
document
.
querySelector
(
"
#loader .progress
"
)
this
.
loaderProgress
=
document
.
querySelector
(
"
#loader .progress
"
)
assets
.
fonts
.
forEach
(
name
=>
{
var
font
=
document
.
createElement
(
"
h1
"
)
font
.
style
.
fontFamily
=
name
font
.
appendChild
(
document
.
createTextNode
(
"
I am a font
"
))
this
.
assetsDiv
.
appendChild
(
font
)
this
.
promises
.
push
(
new
Promise
((
resolve
,
reject
)
=>
{
FontDetect
.
onFontLoaded
(
name
,
resolve
,
reject
,
{
msTimeout
:
90000
})
}))
})
var
fontDetectDiv
=
document
.
getElementById
(
"
fontdetectHelper
"
)
fontDetectDiv
.
parentNode
.
removeChild
(
fontDetectDiv
)
assets
.
img
.
forEach
(
name
=>
{
var
id
=
this
.
getFilename
(
name
)
var
image
=
document
.
createElement
(
"
img
"
)
this
.
promises
.
push
(
pageEvents
.
load
(
image
))
image
.
id
=
name
image
.
src
=
"
/assets/img/
"
+
name
this
.
assetsDiv
.
appendChild
(
image
)
assets
.
image
[
id
]
=
image
})
snd
.
buffer
=
new
SoundBuffer
()
snd
.
buffer
=
new
SoundBuffer
()
snd
.
musicGain
=
snd
.
buffer
.
createGain
()
snd
.
musicGain
=
snd
.
buffer
.
createGain
()
snd
.
sfxGain
=
snd
.
buffer
.
createGain
()
snd
.
sfxGain
=
snd
.
buffer
.
createGain
()
...
@@ -48,46 +26,79 @@ class Loader{
...
@@ -48,46 +26,79 @@ class Loader{
)
)
snd
.
sfxLoudGain
.
setVolume
(
1.2
)
snd
.
sfxLoudGain
.
setVolume
(
1.2
)
assets
.
audioSfx
.
forEach
(
name
=>
{
snd
.
buffer
.
load
(
"
/assets/audio/
"
+
assets
.
audioOgg
).
then
(()
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxGain
))
this
.
oggNotSupported
=
false
})
},
()
=>
{
assets
.
audioMusic
.
forEach
(
name
=>
{
this
.
oggNotSupported
=
true
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
musicGain
))
}).
then
(()
=>
{
})
assets
.
audioSfxLR
.
forEach
(
name
=>
{
assets
.
fonts
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxGain
).
then
(
sound
=>
{
var
font
=
document
.
createElement
(
"
h1
"
)
font
.
style
.
fontFamily
=
name
font
.
appendChild
(
document
.
createTextNode
(
"
I am a font
"
))
this
.
assetsDiv
.
appendChild
(
font
)
this
.
promises
.
push
(
new
Promise
((
resolve
,
reject
)
=>
{
FontDetect
.
onFontLoaded
(
name
,
resolve
,
reject
,
{
msTimeout
:
90000
})
}))
})
var
fontDetectDiv
=
document
.
getElementById
(
"
fontdetectHelper
"
)
fontDetectDiv
.
parentNode
.
removeChild
(
fontDetectDiv
)
assets
.
img
.
forEach
(
name
=>
{
var
id
=
this
.
getFilename
(
name
)
var
id
=
this
.
getFilename
(
name
)
assets
.
sounds
[
id
+
"
_p1
"
]
=
assets
.
sounds
[
id
].
copy
(
snd
.
sfxGainL
)
var
image
=
document
.
createElement
(
"
img
"
)
assets
.
sounds
[
id
+
"
_p2
"
]
=
assets
.
sounds
[
id
].
copy
(
snd
.
sfxGainR
)
this
.
promises
.
push
(
pageEvents
.
load
(
image
))
}))
image
.
id
=
name
})
image
.
src
=
"
/assets/img/
"
+
name
assets
.
audioSfxLoud
.
forEach
(
name
=>
{
this
.
assetsDiv
.
appendChild
(
image
)
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxLoudGain
))
assets
.
image
[
id
]
=
image
})
})
p2
=
new
P2Connection
()
assets
.
audioSfx
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxGain
))
})
assets
.
audioMusic
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
musicGain
))
})
assets
.
audioSfxLR
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxGain
).
then
(
sound
=>
{
var
id
=
this
.
getFilename
(
name
)
assets
.
sounds
[
id
+
"
_p1
"
]
=
assets
.
sounds
[
id
].
copy
(
snd
.
sfxGainL
)
assets
.
sounds
[
id
+
"
_p2
"
]
=
assets
.
sounds
[
id
].
copy
(
snd
.
sfxGainR
)
}))
})
assets
.
audioSfxLoud
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxLoudGain
))
})
this
.
promises
.
push
(
this
.
ajax
(
"
/api/songs
"
).
then
(
songs
=>
{
p2
=
new
P2Connection
()
assets
.
songs
=
JSON
.
parse
(
songs
)
}))
this
.
promises
.
push
(
this
.
ajax
(
"
/api/songs
"
).
then
(
songs
=>
{
assets
.
songs
=
JSON
.
parse
(
songs
)
assets
.
views
.
forEach
(
name
=>
{
var
id
=
this
.
getFilename
(
name
)
this
.
promises
.
push
(
this
.
ajax
(
"
src/views/
"
+
name
).
then
(
page
=>
{
assets
.
pages
[
id
]
=
page
}))
}))
assets
.
views
.
forEach
(
name
=>
{
var
id
=
this
.
getFilename
(
name
)
this
.
promises
.
push
(
this
.
ajax
(
"
src/views/
"
+
name
).
then
(
page
=>
{
assets
.
pages
[
id
]
=
page
}))
})
this
.
promises
.
forEach
(
promise
=>
{
promise
.
then
(
this
.
assetLoaded
.
bind
(
this
))
})
Promise
.
all
(
this
.
promises
).
then
(()
=>
{
this
.
clean
()
this
.
callback
()
},
this
.
errorMsg
.
bind
(
this
))
})
})
this
.
promises
.
forEach
(
promise
=>
{
promise
.
then
(
this
.
assetLoaded
.
bind
(
this
))
})
Promise
.
all
(
this
.
promises
).
then
(()
=>
{
this
.
clean
()
this
.
callback
()
},
this
.
errorMsg
.
bind
(
this
))
}
}
loadSound
(
name
,
gain
){
loadSound
(
name
,
gain
){
if
(
this
.
oggNotSupported
&&
name
.
endsWith
(
"
.ogg
"
)){
name
=
name
.
slice
(
0
,
-
4
)
+
"
.wav
"
}
var
id
=
this
.
getFilename
(
name
)
var
id
=
this
.
getFilename
(
name
)
return
gain
.
load
(
"
/assets/audio/
"
+
name
).
then
(
sound
=>
{
return
gain
.
load
(
"
/assets/audio/
"
+
name
).
then
(
sound
=>
{
assets
.
sounds
[
id
]
=
sound
assets
.
sounds
[
id
]
=
sound
...
...
public/src/js/view.js
View file @
869857d3
...
@@ -498,7 +498,7 @@ class View{
...
@@ -498,7 +498,7 @@ class View{
}
}
}
else
if
(
!
circle
.
isAnimated
()){
}
else
if
(
!
circle
.
isAnimated
()){
// Start animation to HP bar
// Start animation to HP bar
circle
.
animate
()
circle
.
animate
(
ms
)
}
}
if
(
ms
>=
circle
.
ms
&&
!
circle
.
gogoChecked
){
if
(
ms
>=
circle
.
ms
&&
!
circle
.
gogoChecked
){
if
(
this
.
gogoTime
!=
circle
.
gogoTime
){
if
(
this
.
gogoTime
!=
circle
.
gogoTime
){
...
@@ -507,10 +507,12 @@ class View{
...
@@ -507,10 +507,12 @@ class View{
circle
.
gogoChecked
=
true
circle
.
gogoChecked
=
true
}
}
if
(
circle
.
isAnimated
()){
if
(
circle
.
isAnimated
()){
var
animationDuration
=
470
var
animT
=
circle
.
getAnimT
()
if
(
ms
<=
finishTime
+
animationDuration
){
var
animationDuration
=
400
var
curveDistance
=
this
.
HPBarX
+
this
.
HPBarW
-
this
.
slotX
if
(
ms
<=
animT
+
animationDuration
){
var
bezierPoint
=
this
.
calcBezierPoint
(
circle
.
getAnimT
(),
[{
var
curveDistance
=
this
.
HPBarX
+
this
.
HPBarW
-
this
.
slotX
-
this
.
HPBarColH
/
2
var
animPoint
=
(
ms
-
animT
)
/
animationDuration
var
bezierPoint
=
this
.
calcBezierPoint
(
this
.
easeOut
(
animPoint
),
[{
x
:
this
.
slotX
+
this
.
circleSize
*
0.4
,
x
:
this
.
slotX
+
this
.
circleSize
*
0.4
,
y
:
this
.
circleY
-
this
.
circleSize
*
0.8
y
:
this
.
circleY
-
this
.
circleSize
*
0.8
},
{
},
{
...
@@ -521,13 +523,9 @@ class View{
...
@@ -521,13 +523,9 @@ class View{
y
:
0
y
:
0
},
{
},
{
x
:
this
.
slotX
+
curveDistance
,
x
:
this
.
slotX
+
curveDistance
,
y
:
this
.
HPbarColY
y
:
this
.
HPbarColY
+
this
.
HPBarColH
/
2
}])
}])
this
.
drawCircle
(
circle
,
{
x
:
bezierPoint
.
x
,
y
:
bezierPoint
.
y
})
this
.
drawCircle
(
circle
,
{
x
:
bezierPoint
.
x
,
y
:
bezierPoint
.
y
})
// Update animation frame
circle
.
incAnimT
()
circle
.
incFrame
()
}
}
else
{
else
{
circle
.
endAnimation
()
circle
.
endAnimation
()
...
@@ -548,6 +546,9 @@ class View{
...
@@ -548,6 +546,9 @@ class View{
}
}
return
data
[
0
]
return
data
[
0
]
}
}
easeOut
(
pos
){
return
Math
.
sin
(
Math
.
PI
/
2
*
pos
)
}
drawCircle
(
circle
,
circlePos
){
drawCircle
(
circle
,
circlePos
){
var
z
=
this
.
canvas
.
scale
var
z
=
this
.
canvas
.
scale
var
fill
,
size
,
faceID
var
fill
,
size
,
faceID
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment