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
5a115040
Commit
5a115040
authored
Oct 25, 2018
by
Bui
Committed by
GitHub
Oct 25, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #60 from LoveEevee/view-rewrite
View: Rewrite
parents
ab2e3d24
378e2753
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
1511 additions
and
967 deletions
+1511
-967
public/src/css/game.css
public/src/css/game.css
+9
-2
public/src/js/assets.js
public/src/js/assets.js
+3
-12
public/src/js/canvasasset.js
public/src/js/canvasasset.js
+2
-3
public/src/js/canvascache.js
public/src/js/canvascache.js
+18
-5
public/src/js/canvasdraw.js
public/src/js/canvasdraw.js
+254
-43
public/src/js/controller.js
public/src/js/controller.js
+20
-11
public/src/js/debug.js
public/src/js/debug.js
+4
-0
public/src/js/element.js
public/src/js/element.js
+0
-49
public/src/js/game.js
public/src/js/game.js
+4
-6
public/src/js/keyboard.js
public/src/js/keyboard.js
+1
-1
public/src/js/loadsong.js
public/src/js/loadsong.js
+1
-1
public/src/js/scalablecanvas.js
public/src/js/scalablecanvas.js
+0
-42
public/src/js/scoresheet.js
public/src/js/scoresheet.js
+21
-14
public/src/js/songselect.js
public/src/js/songselect.js
+143
-90
public/src/js/view.js
public/src/js/view.js
+994
-655
public/src/js/viewassets.js
public/src/js/viewassets.js
+37
-30
public/src/views/game.html
public/src/views/game.html
+0
-1
templates/index.html
templates/index.html
+0
-2
No files found.
public/src/css/game.css
View file @
5a115040
#game
{
#game
{
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
position
:
a
sb
olute
;
position
:
a
bs
olute
;
overflow
:
hidden
;
overflow
:
hidden
;
background-size
:
cover
;
background-size
:
cover
;
background-position
:
center
;
}
}
#game
.default-bg
{
#game
.default-bg
{
background-size
:
calc
(
100vh
/
720
*
512
);
background-size
:
calc
(
100vh
/
720
*
512
);
...
@@ -70,7 +71,7 @@
...
@@ -70,7 +71,7 @@
#touch-buttons
{
#touch-buttons
{
display
:
none
;
display
:
none
;
position
:
absolute
;
position
:
absolute
;
top
:
6.5
vh
;
top
:
8
vh
;
right
:
2vh
;
right
:
2vh
;
opacity
:
0.5
;
opacity
:
0.5
;
z-index
:
5
;
z-index
:
5
;
...
@@ -79,6 +80,12 @@
...
@@ -79,6 +80,12 @@
width
:
12.5vmin
;
width
:
12.5vmin
;
height
:
12.5vmin
;
height
:
12.5vmin
;
}
}
.portrait
#touch-buttons
{
top
:
11vh
;
}
.touchp2
#touch-buttons
{
top
:
-1.9vh
;
}
.touch-visible
#touch-drum
,
.touch-visible
#touch-drum
,
.touch-visible
#touch-buttons
{
.touch-visible
#touch-buttons
{
display
:
block
;
display
:
block
;
...
...
public/src/js/assets.js
View file @
5a115040
...
@@ -2,20 +2,11 @@ var assets = {
...
@@ -2,20 +2,11 @@ var assets = {
"
img
"
:
[
"
img
"
:
[
"
title-screen.png
"
,
"
title-screen.png
"
,
"
logo-big.png
"
,
"
logo-big.png
"
,
"
don-0.png
"
,
"
notes.png
"
,
"
don-1.png
"
,
"
notes_drumroll.png
"
,
"
big-don-0.png
"
,
"
notes_hit.png
"
,
"
big-don-1.png
"
,
"
balloon.png
"
,
"
balloon.png
"
,
"
taiko.png
"
,
"
taiko.png
"
,
"
taiko-key-blue.png
"
,
"
taiko-key-red.png
"
,
"
hp-bar-bg.png
"
,
"
hp-bar-colour.png
"
,
"
score-0.png
"
,
"
score-0-b.png
"
,
"
score-230.png
"
,
"
score-450.png
"
,
"
dancing-don.gif
"
,
"
dancing-don.gif
"
,
"
bg-pattern-1.png
"
,
"
bg-pattern-1.png
"
,
"
muzu_easy.png
"
,
"
muzu_easy.png
"
,
...
...
public/src/js/canvasasset.js
View file @
5a115040
...
@@ -27,6 +27,7 @@ class CanvasAsset{
...
@@ -27,6 +27,7 @@ class CanvasAsset{
}
else
{
}
else
{
frame
=
this
.
mod
(
this
.
animation
,
index
)
frame
=
this
.
mod
(
this
.
animation
,
index
)
}
}
this
.
ctx
.
save
()
var
pos
=
this
.
position
(
frame
)
var
pos
=
this
.
position
(
frame
)
if
(
this
.
image
){
if
(
this
.
image
){
this
.
ctx
.
drawImage
(
this
.
image
,
this
.
ctx
.
drawImage
(
this
.
image
,
...
@@ -35,9 +36,7 @@ class CanvasAsset{
...
@@ -35,9 +36,7 @@ class CanvasAsset{
pos
.
x
,
pos
.
y
,
pos
.
w
,
pos
.
h
pos
.
x
,
pos
.
y
,
pos
.
w
,
pos
.
h
)
)
}
}
if
(
pos
.
callback
){
this
.
ctx
.
restore
()
pos
.
callback
()
}
}
}
}
}
mod
(
length
,
index
){
mod
(
length
,
index
){
...
...
public/src/js/canvascache.js
View file @
5a115040
class
CanvasCache
{
class
CanvasCache
{
constructor
(
w
,
h
,
scale
){
constructor
(
w
,
h
,
scale
){
this
.
canvas
=
document
.
createElement
(
"
canvas
"
)
this
.
ctx
=
this
.
canvas
.
getContext
(
"
2d
"
)
this
.
map
=
new
Map
()
if
(
w
){
if
(
w
){
this
.
resize
(
w
,
h
,
scale
)
this
.
resize
(
w
,
h
,
scale
)
}
}
}
}
resize
(
w
,
h
,
scale
){
resize
(
w
,
h
,
scale
){
if
(
this
.
canvas
){
this
.
map
.
clear
()
this
.
map
.
clear
()
}
else
{
this
.
map
=
new
Map
()
this
.
canvas
=
document
.
createElement
(
"
canvas
"
)
this
.
ctx
=
this
.
canvas
.
getContext
(
"
2d
"
)
}
this
.
scale
=
scale
this
.
scale
=
scale
this
.
x
=
0
this
.
x
=
0
this
.
y
=
0
this
.
y
=
0
...
@@ -20,8 +23,11 @@ class CanvasCache{
...
@@ -20,8 +23,11 @@ class CanvasCache{
this
.
canvas
.
height
=
this
.
h
*
this
.
scale
this
.
canvas
.
height
=
this
.
h
*
this
.
scale
this
.
ctx
.
scale
(
this
.
scale
,
this
.
scale
)
this
.
ctx
.
scale
(
this
.
scale
,
this
.
scale
)
}
}
get
(
config
,
callback
){
get
(
config
,
callback
,
setOnly
){
var
img
=
this
.
map
.
get
(
config
.
id
)
var
img
=
this
.
map
.
get
(
config
.
id
)
if
(
img
&&
setOnly
||
!
img
&&
!
callback
){
return
}
var
saved
=
false
var
saved
=
false
if
(
!
img
){
if
(
!
img
){
var
w
=
config
.
w
var
w
=
config
.
w
...
@@ -50,6 +56,10 @@ class CanvasCache{
...
@@ -50,6 +56,10 @@ class CanvasCache{
callback
(
this
.
ctx
)
callback
(
this
.
ctx
)
}
}
if
(
setOnly
){
this
.
ctx
.
restore
()
return
}
var
z
=
this
.
scale
var
z
=
this
.
scale
config
.
ctx
.
drawImage
(
this
.
canvas
,
config
.
ctx
.
drawImage
(
this
.
canvas
,
img
.
x
*
z
|
0
,
img
.
y
*
z
|
0
,
img
.
w
*
z
|
0
,
img
.
h
*
z
|
0
,
img
.
x
*
z
|
0
,
img
.
y
*
z
|
0
,
img
.
w
*
z
|
0
,
img
.
h
*
z
|
0
,
...
@@ -59,6 +69,9 @@ class CanvasCache{
...
@@ -59,6 +69,9 @@ class CanvasCache{
this
.
ctx
.
restore
()
this
.
ctx
.
restore
()
}
}
}
}
set
(
config
,
callback
){
return
this
.
get
(
config
,
callback
,
true
)
}
clean
(){
clean
(){
delete
this
.
map
delete
this
.
map
delete
this
.
ctx
delete
this
.
ctx
...
...
public/src/js/canvasdraw.js
View file @
5a115040
...
@@ -39,6 +39,13 @@
...
@@ -39,6 +39,13 @@
this
.
crownPath
=
new
Path2D
(
"
m82 21c0-4 3-6 5.5-6 2.5 0 5.5 2 5.5 6 0 4-3 6-5.5 6C85 27 82 25 82 21ZM41.5 6c0-4 3-6 5.5-6 2.5 0 5.5 2 5.5 6 0 4-3 6-5.5 6-2.5 0-5.5-2-5.5-6zM1 21C1 17 4 15 6.5 15 9 15 12 17 12 21 12 25 9 27 6.5 27 4 27 1 25 1 21Zm12 46h68l2 11H11ZM13 62 5 18 29 34 47 6 65 34 89 18 81 62Z
"
)
this
.
crownPath
=
new
Path2D
(
"
m82 21c0-4 3-6 5.5-6 2.5 0 5.5 2 5.5 6 0 4-3 6-5.5 6C85 27 82 25 82 21ZM41.5 6c0-4 3-6 5.5-6 2.5 0 5.5 2 5.5 6 0 4-3 6-5.5 6-2.5 0-5.5-2-5.5-6zM1 21C1 17 4 15 6.5 15 9 15 12 17 12 21 12 25 9 27 6.5 27 4 27 1 25 1 21Zm12 46h68l2 11H11ZM13 62 5 18 29 34 47 6 65 34 89 18 81 62Z
"
)
this
.
soulPath
=
new
Path2D
(
"
m37 29c1-4 7 2 7 4 0 1-2 2-4 2-1 0-1-4-3-6zm-4-7c3 1 5 3 4 5-1 2-3 3-3 4 3-2 5-2 5-2 0 0-1 3-5 5-4 3-5-1-3-4 2-3 3-6 0-7zm-3 8c1 3-5 10 8 7 6-1 2-4 2-4 5 1 7 3 7 5 0 3-8 4-12 4-4 0-9-2-9-5 0 0 0-6-1-8 0-3 3-3 5 1zM20 23h8C27 27 20 44 9 42 18 36 23 28 21 26 19 24 20 23 20 23Zm0-6c4-2 9-4 14-2v2c-5 0-9 1-14 2zm8-7v12h-4c2-1 1-9-1-10zm-6 12c3 0 10-2 10-2 0 0 1-10 0-10-5 1-8 3-12 3 0 0 2 5 2 9zm0-12c0 0 6-1 9-3 3-2 9 3 8 6-1 3-2 6-4 9-2 2-15 2-15 2-1 0-3-7-2-11zM21 0c8 0 10 3 8 5 0 0-6 7-15 10C22 8 23 3 23 3 23 1 21 0 21 0ZM5 9c-1 3 2 6 4 6 5-1 13-6 4-7-3 0-5 5-8 1zm7 17c2-1 4-1 6 1 2 2 1 6-2 6-1 0-2-2-2-2-1-2-3-4-2-5zm2 4c-3 2-4 5-5 6-1 1-4 2-6-2-1-2 0-3 2-5l4-4c0-1-1 0-4 1-2 1-5-2-4-4 2-5 1 0 3-1 6-4 9-5 11-3 2 2 0 3-2 5-1 1-3 4-4 6 0 1 3-1 4-2
"
)
this
.
optionsPath
=
{
shadow
:
new
Path2D
(
"
M4-1V8H9V0l1-1 3 6v4l-4 5v10l4 5v4l-2 4-2 1V30H4L5 37 3 38 0 33V29L4 24V14L0 9V5L3 0Z
"
),
main
:
new
Path2D
(
"
M4 0V8H9V0h1l3 5v4l-4 5v10l4 5v4l-3 5H9V30H4v8H3L0 33V29L4 24V14L0 9V5L3 0Z
"
)
}
this
.
regex
=
{
this
.
regex
=
{
comma
:
/
[
,.
]
/
,
comma
:
/
[
,.
]
/
,
ideographicComma
:
/
[
、。
]
/
,
ideographicComma
:
/
[
、。
]
/
,
...
@@ -76,11 +83,25 @@
...
@@ -76,11 +83,25 @@
var
h
=
config
.
h
var
h
=
config
.
h
var
r
=
config
.
radius
var
r
=
config
.
radius
ctx
.
beginPath
()
ctx
.
beginPath
()
ctx
.
arc
(
x
+
r
,
y
+
r
,
r
,
Math
.
PI
,
Math
.
PI
*
1.5
)
this
.
roundedCorner
(
ctx
,
x
,
y
,
r
,
0
)
ctx
.
arc
(
x
+
w
-
r
,
y
+
r
,
r
,
Math
.
PI
*
1.5
,
0
)
this
.
roundedCorner
(
ctx
,
x
+
w
,
y
,
r
,
1
)
ctx
.
arc
(
x
+
w
-
r
,
y
+
h
-
r
,
r
,
0
,
Math
.
PI
/
2
)
this
.
roundedCorner
(
ctx
,
x
+
w
,
y
+
h
,
r
,
2
)
ctx
.
arc
(
x
+
r
,
y
+
h
-
r
,
r
,
Math
.
PI
/
2
,
Math
.
PI
)
this
.
roundedCorner
(
ctx
,
x
,
y
+
h
,
r
,
3
)
ctx
.
lineTo
(
x
,
y
+
r
)
ctx
.
closePath
()
}
roundedCorner
(
ctx
,
x
,
y
,
r
,
rotation
){
var
pi
=
Math
.
PI
switch
(
rotation
){
case
0
:
return
ctx
.
arc
(
x
+
r
,
y
+
r
,
r
,
pi
,
pi
/
-
2
)
case
1
:
return
ctx
.
arc
(
x
-
r
,
y
+
r
,
r
,
pi
/
-
2
,
0
)
case
2
:
return
ctx
.
arc
(
x
-
r
,
y
-
r
,
r
,
0
,
pi
/
2
)
case
3
:
return
ctx
.
arc
(
x
+
r
,
y
-
r
,
r
,
pi
/
2
,
pi
)
}
}
}
songFrame
(
config
){
songFrame
(
config
){
...
@@ -428,6 +449,9 @@
...
@@ -428,6 +449,9 @@
}
}
ctx
.
translate
(
config
.
x
,
config
.
y
)
ctx
.
translate
(
config
.
x
,
config
.
y
)
if
(
config
.
scale
){
ctx
.
scale
(
config
.
scale
[
0
],
config
.
scale
[
1
])
}
var
scale
=
1
var
scale
=
1
if
(
config
.
width
&&
drawnWidth
>
config
.
width
){
if
(
config
.
width
&&
drawnWidth
>
config
.
width
){
scale
=
config
.
width
/
drawnWidth
scale
=
config
.
width
/
drawnWidth
...
@@ -438,7 +462,13 @@
...
@@ -438,7 +462,13 @@
ctx
.
textAlign
=
"
center
"
ctx
.
textAlign
=
"
center
"
for
(
let
layer
of
layers
){
for
(
let
layer
of
layers
){
var
savedLayer
=
false
var
action
=
"
strokeText
"
var
action
=
"
strokeText
"
if
(
layer
.
scale
){
savedLayer
=
true
ctx
.
save
()
ctx
.
scale
(
layer
.
scale
[
0
],
layer
.
scale
[
1
])
}
if
(
layer
.
outline
){
if
(
layer
.
outline
){
ctx
.
strokeStyle
=
layer
.
outline
ctx
.
strokeStyle
=
layer
.
outline
ctx
.
lineJoin
=
"
round
"
ctx
.
lineJoin
=
"
round
"
...
@@ -452,7 +482,10 @@
...
@@ -452,7 +482,10 @@
action
=
"
fillText
"
action
=
"
fillText
"
}
}
if
(
layer
.
shadow
){
if
(
layer
.
shadow
){
if
(
!
savedLayer
){
savedLayer
=
true
ctx
.
save
()
ctx
.
save
()
}
this
.
shadow
({
this
.
shadow
({
ctx
:
ctx
,
ctx
:
ctx
,
fill
:
"
rgba(0, 0, 0,
"
+
(
1
/
(
layer
.
shadow
[
3
]
||
2
))
+
"
)
"
,
fill
:
"
rgba(0, 0, 0,
"
+
(
1
/
(
layer
.
shadow
[
3
]
||
2
))
+
"
)
"
,
...
@@ -501,7 +534,7 @@
...
@@ -501,7 +534,7 @@
}
}
offsetX
+=
symbol
.
w
*
mul
offsetX
+=
symbol
.
w
*
mul
}
}
if
(
layer
.
shadow
){
if
(
savedLayer
){
ctx
.
restore
()
ctx
.
restore
()
}
}
}
}
...
@@ -538,6 +571,8 @@
...
@@ -538,6 +571,8 @@
diffOptionsIcon
(
config
){
diffOptionsIcon
(
config
){
var
ctx
=
config
.
ctx
var
ctx
=
config
.
ctx
ctx
.
save
()
ctx
.
save
()
if
(
config
.
iconName
===
"
back
"
){
ctx
.
translate
(
config
.
x
-
21
,
config
.
y
-
21
)
ctx
.
translate
(
config
.
x
-
21
,
config
.
y
-
21
)
var
drawLine
=
y
=>
{
var
drawLine
=
y
=>
{
...
@@ -574,6 +609,21 @@
...
@@ -574,6 +609,21 @@
ctx
.
globalCompositeOperation
=
"
darken
"
ctx
.
globalCompositeOperation
=
"
darken
"
drawLine
(
11
)
drawLine
(
11
)
drawTriangle
()
drawTriangle
()
}
else
if
(
config
.
iconName
===
"
options
"
){
ctx
.
translate
(
config
.
x
,
config
.
y
)
ctx
.
rotate
(
-
55
*
Math
.
PI
/
180
)
ctx
.
translate
(
-
6
,
-
20
)
ctx
.
strokeStyle
=
"
#000
"
ctx
.
lineWidth
=
6
ctx
.
stroke
(
this
.
optionsPath
.
main
)
ctx
.
translate
(
-
2
,
2
)
ctx
.
stroke
(
this
.
optionsPath
.
main
)
ctx
.
fillStyle
=
"
#7e7c76
"
ctx
.
fill
(
this
.
optionsPath
.
shadow
)
ctx
.
translate
(
2
,
-
2
)
ctx
.
fillStyle
=
"
#d9d6ce
"
ctx
.
fill
(
this
.
optionsPath
.
main
)
}
ctx
.
restore
()
ctx
.
restore
()
}
}
...
@@ -676,9 +726,13 @@
...
@@ -676,9 +726,13 @@
ctx
.
scale
(
1
/
mul
,
1
/
mul
)
ctx
.
scale
(
1
/
mul
,
1
/
mul
)
}
}
ctx
.
fillStyle
=
ctx
.
createPattern
(
config
.
img
,
"
repeat
"
)
ctx
.
fillStyle
=
ctx
.
createPattern
(
config
.
img
,
"
repeat
"
)
if
(
config
.
shape
){
config
.
shape
(
ctx
,
mul
)
}
else
{
ctx
.
beginPath
()
ctx
.
beginPath
()
ctx
.
rect
(
config
.
x
*
mul
,
config
.
y
*
mul
,
config
.
w
*
mul
,
config
.
h
*
mul
)
ctx
.
rect
(
config
.
x
*
mul
,
config
.
y
*
mul
,
config
.
w
*
mul
,
config
.
h
*
mul
)
ctx
.
translate
(
config
.
dx
,
config
.
dy
)
}
ctx
.
translate
(
config
.
dx
*
mul
,
config
.
dy
*
mul
)
ctx
.
fill
()
ctx
.
fill
()
ctx
.
restore
()
ctx
.
restore
()
...
@@ -692,6 +746,9 @@
...
@@ -692,6 +746,9 @@
if
(
config
.
scale
){
if
(
config
.
scale
){
ctx
.
scale
(
config
.
scale
,
config
.
scale
)
ctx
.
scale
(
config
.
scale
,
config
.
scale
)
}
}
if
(
config
.
align
===
"
center
"
){
ctx
.
translate
(
config
.
score
===
"
bad
"
?
-
49
/
2
:
-
23
/
2
,
0
)
}
ctx
.
strokeStyle
=
"
#000
"
ctx
.
strokeStyle
=
"
#000
"
ctx
.
lineWidth
=
7
ctx
.
lineWidth
=
7
if
(
config
.
score
===
"
good
"
){
if
(
config
.
score
===
"
good
"
){
...
@@ -790,6 +847,160 @@
...
@@ -790,6 +847,160 @@
ctx
.
restore
()
ctx
.
restore
()
}
}
gauge
(
config
){
var
ctx
=
config
.
ctx
ctx
.
save
()
ctx
.
translate
(
config
.
x
,
config
.
y
)
if
(
config
.
scale
){
ctx
.
scale
(
config
.
scale
,
config
.
scale
)
}
ctx
.
translate
(
-
788
,
0
)
var
firstTop
=
config
.
multiplayer
?
0
:
30
var
secondTop
=
config
.
multiplayer
?
0
:
8
var
cleared
=
config
.
percentage
-
1
/
50
>=
config
.
clear
var
gaugeW
=
14
*
50
var
gaugeClear
=
gaugeW
*
config
.
clear
var
gaugeFilled
=
gaugeW
*
config
.
percentage
ctx
.
fillStyle
=
"
#000
"
ctx
.
beginPath
()
if
(
config
.
scoresheet
){
ctx
.
moveTo
(
-
4
,
26
)
ctx
.
lineTo
(
gaugeClear
-
4
,
26
)
this
.
roundedCorner
(
ctx
,
gaugeClear
-
4
,
4
,
13
,
0
)
this
.
roundedCorner
(
ctx
,
760
,
4
,
13
,
1
)
ctx
.
lineTo
(
760
,
56
)
ctx
.
lineTo
(
-
4
,
56
)
}
else
if
(
config
.
multiplayer
){
ctx
.
moveTo
(
gaugeClear
-
7
,
27
)
ctx
.
lineTo
(
788
,
27
)
ctx
.
lineTo
(
788
,
52
)
this
.
roundedCorner
(
ctx
,
gaugeClear
-
7
,
52
,
18
,
3
)
}
else
{
ctx
.
moveTo
(
gaugeClear
-
7
,
24
)
this
.
roundedCorner
(
ctx
,
gaugeClear
-
7
,
0
,
18
,
0
)
ctx
.
lineTo
(
788
,
0
)
ctx
.
lineTo
(
788
,
24
)
}
ctx
.
fill
()
if
(
gaugeFilled
<=
gaugeClear
){
ctx
.
fillStyle
=
"
#680000
"
var
x
=
Math
.
max
(
0
,
gaugeFilled
-
5
)
ctx
.
fillRect
(
x
,
firstTop
,
gaugeClear
-
x
+
2
,
22
)
}
if
(
gaugeFilled
>
0
){
var
w
=
Math
.
min
(
gaugeClear
+
1
,
gaugeFilled
-
4
)
ctx
.
fillStyle
=
"
#ff3508
"
ctx
.
fillRect
(
0
,
firstTop
+
2
,
w
,
20
)
ctx
.
fillStyle
=
"
#ff9e94
"
ctx
.
fillRect
(
0
,
firstTop
,
w
,
3
)
}
if
(
gaugeFilled
<
gaugeW
-
4
){
ctx
.
fillStyle
=
"
#684c00
"
var
x
=
Math
.
max
(
gaugeClear
+
9
,
gaugeFilled
-
gaugeClear
+
9
)
ctx
.
fillRect
(
x
,
secondTop
,
gaugeW
-
4
-
x
,
44
)
}
if
(
gaugeFilled
>
gaugeClear
+
14
){
var
w
=
Math
.
min
(
gaugeW
-
4
,
gaugeFilled
-
gaugeClear
-
14
)
ctx
.
fillStyle
=
"
#ff0
"
ctx
.
fillRect
(
gaugeClear
+
9
,
secondTop
+
2
,
w
,
42
)
ctx
.
fillStyle
=
"
#fff
"
ctx
.
fillRect
(
gaugeClear
+
9
,
secondTop
,
w
,
3
)
}
ctx
.
fillStyle
=
cleared
?
"
#ff0
"
:
"
#684c00
"
ctx
.
beginPath
()
if
(
config
.
multiplayer
){
this
.
roundedCorner
(
ctx
,
gaugeClear
,
secondTop
+
44
,
10
,
3
)
ctx
.
lineTo
(
gaugeClear
,
secondTop
)
ctx
.
lineTo
(
gaugeClear
+
10
,
secondTop
)
}
else
{
ctx
.
moveTo
(
gaugeClear
,
secondTop
+
44
)
this
.
roundedCorner
(
ctx
,
gaugeClear
,
secondTop
,
10
,
0
)
ctx
.
lineTo
(
gaugeClear
+
10
,
secondTop
+
44
)
}
ctx
.
fill
()
if
(
cleared
){
ctx
.
save
()
ctx
.
clip
()
ctx
.
fillStyle
=
"
#fff
"
ctx
.
fillRect
(
gaugeClear
,
secondTop
,
10
,
3
)
ctx
.
restore
()
}
ctx
.
strokeStyle
=
"
rgba(0, 0, 0, 0.16)
"
ctx
.
beginPath
()
ctx
.
lineWidth
=
5
for
(
var
i
=
0
;
i
<
49
;
i
++
){
var
x
=
14
+
i
*
14
-
ctx
.
lineWidth
/
2
if
(
i
===
26
){
ctx
.
stroke
()
ctx
.
beginPath
()
ctx
.
lineWidth
=
4
}
ctx
.
moveTo
(
x
,
x
<
gaugeClear
?
firstTop
:
secondTop
)
ctx
.
lineTo
(
x
,
x
<
gaugeClear
?
firstTop
+
22
:
secondTop
+
44
)
}
ctx
.
stroke
()
this
.
layeredText
({
ctx
:
ctx
,
text
:
"
クリア
"
,
fontSize
:
18
,
fontFamily
:
config
.
font
,
x
:
gaugeClear
-
6
,
y
:
config
.
multiplayer
?
22
:
11
,
letterSpacing
:
-
2
},
[
{
scale
:
[
1.1
,
1.01
],
outline
:
"
#000
"
,
letterBorder
:
6
},
{
scale
:
[
1.11
,
1
],
fill
:
cleared
?
"
#fff
"
:
"
#737373
"
}
])
ctx
.
restore
()
}
soul
(
config
){
var
ctx
=
config
.
ctx
ctx
.
save
()
ctx
.
translate
(
config
.
x
,
config
.
y
)
if
(
config
.
scale
){
ctx
.
scale
(
config
.
scale
,
config
.
scale
)
}
ctx
.
translate
(
-
23
,
-
21
)
ctx
.
fillStyle
=
config
.
cleared
?
"
#fff
"
:
"
#737373
"
ctx
.
fill
(
this
.
soulPath
)
ctx
.
restore
()
}
slot
(
ctx
,
x
,
y
,
size
){
var
mul
=
size
/
106
ctx
.
save
()
ctx
.
globalAlpha
=
0.7
ctx
.
globalCompositeOperation
=
"
screen
"
ctx
.
fillStyle
=
"
#444544
"
ctx
.
beginPath
()
ctx
.
arc
(
x
,
y
,
26
*
mul
,
0
,
Math
.
PI
*
2
)
ctx
.
fill
()
ctx
.
lineWidth
=
3
ctx
.
strokeStyle
=
"
#9c9e9c
"
ctx
.
beginPath
()
ctx
.
arc
(
x
,
y
,
33.5
*
mul
,
0
,
Math
.
PI
*
2
)
ctx
.
stroke
()
ctx
.
lineWidth
=
3.5
ctx
.
strokeStyle
=
"
#5d5e5d
"
ctx
.
beginPath
()
ctx
.
arc
(
x
,
y
,
51.5
*
mul
,
0
,
Math
.
PI
*
2
)
ctx
.
stroke
()
ctx
.
restore
()
}
alpha
(
amount
,
ctx
,
callback
){
alpha
(
amount
,
ctx
,
callback
){
if
(
amount
>=
1
){
if
(
amount
>=
1
){
return
callback
(
ctx
)
return
callback
(
ctx
)
...
...
public/src/js/controller.js
View file @
5a115040
...
@@ -81,6 +81,17 @@ class Controller{
...
@@ -81,6 +81,17 @@ class Controller{
if
(
this
.
syncWith
){
if
(
this
.
syncWith
){
this
.
syncWith
.
mainLoop
()
this
.
syncWith
.
mainLoop
()
}
}
if
(
this
.
scoresheet
){
if
(
this
.
view
.
ctx
){
this
.
view
.
ctx
.
save
()
this
.
view
.
ctx
.
setTransform
(
1
,
0
,
0
,
1
,
0
,
0
)
}
this
.
scoresheet
.
redraw
()
if
(
this
.
view
.
ctx
){
this
.
view
.
ctx
.
restore
()
}
}
})
})
}
}
var
ms
=
this
.
game
.
elapsedTime
var
ms
=
this
.
game
.
elapsedTime
...
@@ -104,10 +115,6 @@ class Controller{
...
@@ -104,10 +115,6 @@ class Controller{
this
.
view
.
refresh
()
this
.
view
.
refresh
()
}
}
this
.
keyboard
.
checkMenuKeys
()
this
.
keyboard
.
checkMenuKeys
()
if
(
this
.
scoresheet
){
this
.
scoresheet
.
redraw
()
}
}
}
}
}
togglePauseMenu
(){
togglePauseMenu
(){
...
@@ -117,11 +124,13 @@ class Controller{
...
@@ -117,11 +124,13 @@ class Controller{
gameEnded
(){
gameEnded
(){
var
score
=
this
.
getGlobalScore
()
var
score
=
this
.
getGlobalScore
()
var
vp
var
vp
if
(
Math
.
round
(
score
.
gauge
/
2
)
-
1
>=
25
){
if
(
score
.
bad
===
0
){
if
(
score
.
bad
===
0
){
vp
=
"
fullcombo
"
vp
=
"
fullcombo
"
this
.
playSoundMeka
(
"
fullcombo
"
,
1.350
)
this
.
playSoundMeka
(
"
fullcombo
"
,
1.350
)
}
else
if
(
score
.
gauge
>=
50
)
{
}
else
{
vp
=
"
clear
"
vp
=
"
clear
"
}
}
else
{
}
else
{
vp
=
"
fail
"
vp
=
"
fail
"
}
}
...
@@ -132,8 +141,8 @@ class Controller{
...
@@ -132,8 +141,8 @@ class Controller{
this
.
scoresheet
=
new
Scoresheet
(
this
,
this
.
getGlobalScore
(),
this
.
multiplayer
)
this
.
scoresheet
=
new
Scoresheet
(
this
,
this
.
getGlobalScore
(),
this
.
multiplayer
)
}
}
}
}
displayScore
(
score
,
notPlayed
){
displayScore
(
score
,
notPlayed
,
bigNote
){
this
.
view
.
displayScore
(
score
,
notPlayed
)
this
.
view
.
displayScore
(
score
,
notPlayed
,
bigNote
)
}
}
songSelection
(
fadeIn
){
songSelection
(
fadeIn
){
if
(
!
fadeIn
){
if
(
!
fadeIn
){
...
...
public/src/js/debug.js
View file @
5a115040
...
@@ -117,6 +117,10 @@ class Debug{
...
@@ -117,6 +117,10 @@ class Debug{
break
break
}
}
}
}
if
(
game
.
mainMusicPlaying
){
game
.
mainMusicPlaying
=
false
game
.
mainAsset
.
stop
()
}
}
}
this
.
autoplayCheckbox
.
checked
=
this
.
controller
.
autoPlayEnabled
this
.
autoplayCheckbox
.
checked
=
this
.
controller
.
autoPlayEnabled
}
}
...
...
public/src/js/element.js
deleted
100644 → 0
View file @
ab2e3d24
function
element
(){
var
parent
var
lasttag
var
createdtag
var
toreturn
=
{}
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
){
var
current
=
arguments
[
i
]
if
(
current
){
if
(
current
.
nodeType
){
parent
=
lasttag
=
current
}
else
if
(
Array
.
isArray
(
current
)){
lasttag
=
parent
for
(
var
j
=
0
;
j
<
current
.
length
;
j
++
){
if
(
current
[
j
]){
if
(
j
==
0
&&
typeof
current
[
j
]
==
"
string
"
){
var
tagname
=
current
[
0
].
split
(
"
#
"
)
lasttag
=
createdtag
=
document
.
createElement
(
tagname
[
0
])
if
(
tagname
[
1
]){
toreturn
[
tagname
[
1
]]
=
createdtag
}
}
else
if
(
current
[
j
].
constructor
==
Object
){
if
(
lasttag
){
for
(
var
value
in
current
[
j
]){
if
(
value
!=
"
style
"
&&
value
in
lasttag
){
lasttag
[
value
]
=
current
[
j
][
value
]
}
else
{
lasttag
.
setAttribute
(
value
,
current
[
j
][
value
])
}
}
}
}
else
{
var
returned
=
element
(
lasttag
,
current
[
j
])
for
(
var
k
in
returned
){
toreturn
[
k
]
=
returned
[
k
]
}
}
}
}
}
else
if
(
current
){
createdtag
=
document
.
createTextNode
(
current
)
}
if
(
parent
&&
createdtag
){
parent
.
appendChild
(
createdtag
)
}
createdtag
=
0
}
}
return
toreturn
}
public/src/js/game.js
View file @
5a115040
...
@@ -116,9 +116,6 @@ class Game{
...
@@ -116,9 +116,6 @@ class Game{
}
}
}
}
}
}
setHPGain
(
gain
){
this
.
HPGain
=
gain
}
checkPlays
(){
checkPlays
(){
var
circles
=
this
.
songData
.
circles
var
circles
=
this
.
songData
.
circles
var
circle
=
circles
[
this
.
currentCircle
]
var
circle
=
circles
[
this
.
currentCircle
]
...
@@ -200,14 +197,15 @@ class Game{
...
@@ -200,14 +197,15 @@ class Game{
if
(
circleStatus
===
230
||
circleStatus
===
450
){
if
(
circleStatus
===
230
||
circleStatus
===
450
){
score
=
circleStatus
score
=
circleStatus
}
}
this
.
controller
.
displayScore
(
score
)
circle
.
played
(
score
,
score
===
0
?
typeDai
:
keyDai
)
this
.
controller
.
displayScore
(
score
,
false
,
typeDai
&&
keyDai
)
}
else
{
}
else
{
this
.
controller
.
displayScore
(
score
,
true
)
circle
.
played
(
-
1
,
typeDai
)
this
.
controller
.
displayScore
(
score
,
true
,
false
)
}
}
this
.
updateCombo
(
score
)
this
.
updateCombo
(
score
)
this
.
updateGlobalScore
(
score
,
typeDai
&&
keyDai
?
2
:
1
,
circle
.
gogoTime
)
this
.
updateGlobalScore
(
score
,
typeDai
&&
keyDai
?
2
:
1
,
circle
.
gogoTime
)
this
.
updateCurrentCircle
()
this
.
updateCurrentCircle
()
circle
.
played
(
score
,
score
===
0
?
typeDai
:
keyDai
)
if
(
this
.
controller
.
multiplayer
==
1
){
if
(
this
.
controller
.
multiplayer
==
1
){
p2
.
send
(
"
note
"
,
{
p2
.
send
(
"
note
"
,
{
score
:
score
,
score
:
score
,
...
...
public/src/js/keyboard.js
View file @
5a115040
...
@@ -111,7 +111,7 @@ class Keyboard{
...
@@ -111,7 +111,7 @@ class Keyboard{
this
.
controller
.
togglePauseMenu
()
this
.
controller
.
togglePauseMenu
()
for
(
var
key
in
this
.
keyTime
){
for
(
var
key
in
this
.
keyTime
){
this
.
keys
[
key
]
=
null
this
.
keys
[
key
]
=
null
this
.
keyTime
[
key
]
=
null
this
.
keyTime
[
key
]
=
-
Infinity
}
}
})
})
var
moveMenuMinus
=
()
=>
{
var
moveMenuMinus
=
()
=>
{
...
...
public/src/js/loadsong.js
View file @
5a115040
...
@@ -94,7 +94,7 @@ class loadSong{
...
@@ -94,7 +94,7 @@ class loadSong{
this
.
clean
()
this
.
clean
()
loader
.
changePage
(
"
game
"
)
loader
.
changePage
(
"
game
"
)
var
taikoGame1
=
new
Controller
(
this
.
selectedSong
,
this
.
songData
,
false
,
1
,
this
.
touchEnabled
)
var
taikoGame1
=
new
Controller
(
this
.
selectedSong
,
this
.
songData
,
false
,
1
,
this
.
touchEnabled
)
var
taikoGame2
=
new
Controller
(
this
.
selectedSong2
,
this
.
song2Data
,
true
,
2
)
var
taikoGame2
=
new
Controller
(
this
.
selectedSong2
,
this
.
song2Data
,
true
,
2
,
this
.
touchEnabled
)
taikoGame1
.
run
(
taikoGame2
)
taikoGame1
.
run
(
taikoGame2
)
}
}
})
})
...
...
public/src/js/scalablecanvas.js
deleted
100644 → 0
View file @
ab2e3d24
class
ScalableCanvas
{
constructor
(
id
,
width
,
height
,
noStyle
){
var
oldCanvas
=
document
.
getElementById
(
id
)
if
(
oldCanvas
){
this
.
canvas
=
oldCanvas
}
else
{
this
.
canvas
=
document
.
createElement
(
"
canvas
"
)
this
.
canvas
.
id
=
id
}
this
.
ctx
=
this
.
canvas
.
getContext
(
"
2d
"
)
this
.
rescale
()
this
.
resize
(
width
,
height
,
noStyle
)
}
resize
(
width
,
height
,
noStyle
){
if
(
width
!=
this
.
width
||
height
!=
this
.
height
){
this
.
width
=
width
this
.
height
=
height
this
.
scaledWidth
=
width
*
this
.
scale
this
.
canvas
.
width
=
this
.
scaledWidth
this
.
scaledHeight
=
height
*
this
.
scale
this
.
canvas
.
height
=
this
.
scaledHeight
if
(
noStyle
||
this
.
scale
==
1
){
if
(
this
.
canvas
.
style
.
width
){
this
.
canvas
.
style
.
width
=
""
}
if
(
this
.
canvas
.
style
.
height
){
this
.
canvas
.
style
.
height
=
""
}
}
else
{
this
.
canvas
.
style
.
width
=
width
+
"
px
"
this
.
canvas
.
style
.
height
=
height
+
"
px
"
}
}
}
rescale
(){
var
scale
=
window
.
devicePixelRatio
||
1
if
(
scale
!=
this
.
scale
){
this
.
ctx
.
scale
(
scale
,
scale
)
this
.
scale
=
scale
}
}
}
\ No newline at end of file
public/src/js/scoresheet.js
View file @
5a115040
...
@@ -416,16 +416,25 @@ class Scoresheet{
...
@@ -416,16 +416,25 @@ class Scoresheet{
results
=
p2
.
results
results
=
p2
.
results
ctx
.
translate
(
0
,
p2Offset
)
ctx
.
translate
(
0
,
p2Offset
)
}
}
ctx
.
drawImage
(
assets
.
image
[
"
hp-bar-bg
"
],
var
gaugePercent
=
Math
.
round
(
results
.
gauge
/
2
)
/
50
552
,
120
,
688
,
48
var
w
=
712
)
this
.
draw
.
gauge
({
var
gauge
=
results
.
gauge
/
100
ctx
:
ctx
,
if
(
gauge
>
0
){
x
:
558
+
w
,
ctx
.
drawImage
(
assets
.
image
[
"
hp-bar-colour
"
],
y
:
116
,
0
,
0
,
650
*
gauge
,
40
,
clear
:
25
/
50
,
557
,
127
,
635
*
gauge
,
37
,
percentage
:
gaugePercent
,
)
font
:
this
.
font
,
}
scale
:
w
/
788
,
scoresheet
:
true
})
this
.
draw
.
soul
({
ctx
:
ctx
,
x
:
1215
,
y
:
144
,
scale
:
36
/
42
,
cleared
:
gaugePercent
-
1
/
50
>=
25
/
50
})
}
}
ctx
.
restore
()
ctx
.
restore
()
}
}
...
@@ -441,10 +450,8 @@ class Scoresheet{
...
@@ -441,10 +450,8 @@ class Scoresheet{
results
=
p2
.
results
results
=
p2
.
results
}
}
var
crownType
=
null
var
crownType
=
null
if
(
results
.
bad
===
"
0
"
){
if
(
Math
.
round
(
results
.
gauge
/
2
)
-
1
>=
25
){
crownType
=
"
gold
"
crownType
=
results
.
bad
===
"
0
"
?
"
gold
"
:
"
silver
"
}
else
if
(
results
.
gauge
>=
50
){
crownType
=
"
silver
"
}
}
if
(
crownType
!==
null
){
if
(
crownType
!==
null
){
noCrownResultWait
=
0
;
noCrownResultWait
=
0
;
...
...
public/src/js/songselect.js
View file @
5a115040
...
@@ -156,6 +156,21 @@ class SongSelect{
...
@@ -156,6 +156,21 @@ class SongSelect{
letterBorder
:
12
letterBorder
:
12
}
}
this
.
diffOptions
=
[{
text
:
"
もどる
"
,
fill
:
"
#efb058
"
,
iconName
:
"
back
"
,
iconFill
:
"
#f7d39c
"
,
letterSpacing
:
4
},
{
text
:
"
演奏オプション
"
,
fill
:
"
#b2e442
"
,
iconName
:
"
options
"
,
iconFill
:
"
#d9f19f
"
,
letterSpacing
:
0
}]
this
.
optionsList
=
[
"
なし
"
,
"
オート
"
,
"
ネットプレイ
"
]
this
.
draw
=
new
CanvasDraw
()
this
.
draw
=
new
CanvasDraw
()
this
.
songTitleCache
=
new
CanvasCache
()
this
.
songTitleCache
=
new
CanvasCache
()
this
.
selectTextCache
=
new
CanvasCache
()
this
.
selectTextCache
=
new
CanvasCache
()
...
@@ -185,7 +200,7 @@ class SongSelect{
...
@@ -185,7 +200,7 @@ class SongSelect{
this
.
playBgm
(
false
)
this
.
playBgm
(
false
)
}
}
if
(
"
selectedDiff
"
in
localStorage
){
if
(
"
selectedDiff
"
in
localStorage
){
this
.
selectedDiff
=
Math
.
min
(
Math
.
max
(
0
,
localStorage
[
"
selectedDiff
"
]
|
0
),
4
)
this
.
selectedDiff
=
Math
.
min
(
Math
.
max
(
0
,
localStorage
[
"
selectedDiff
"
]
|
0
),
this
.
diffOptions
.
length
+
3
)
}
}
this
.
songSelect
=
document
.
getElementById
(
"
song-select
"
)
this
.
songSelect
=
document
.
getElementById
(
"
song-select
"
)
...
@@ -202,7 +217,8 @@ class SongSelect{
...
@@ -202,7 +217,8 @@ class SongSelect{
ura
:
0
,
ura
:
0
,
moveHover
:
null
,
moveHover
:
null
,
locked
:
true
,
locked
:
true
,
hasPointer
:
false
hasPointer
:
false
,
options
:
0
}
}
this
.
songSelecting
=
{
this
.
songSelecting
=
{
speed
:
800
,
speed
:
800
,
...
@@ -218,6 +234,8 @@ class SongSelect{
...
@@ -218,6 +234,8 @@ class SongSelect{
"
8
"
:
[
"
a
"
],
"
8
"
:
[
"
a
"
],
"
37
"
:
[
"
l
"
,
"
lb
"
,
"
lt
"
,
"
lsl
"
],
"
37
"
:
[
"
l
"
,
"
lb
"
,
"
lt
"
,
"
lsl
"
],
"
39
"
:
[
"
r
"
,
"
rb
"
,
"
rt
"
,
"
lsr
"
],
"
39
"
:
[
"
r
"
,
"
rb
"
,
"
rt
"
,
"
lsr
"
],
"
38
"
:
[
"
u
"
,
"
lsu
"
],
"
40
"
:
[
"
d
"
,
"
lsd
"
],
"
ctrl
"
:
[
"
y
"
],
"
ctrl
"
:
[
"
y
"
],
"
shift
"
:
[
"
x
"
]
"
shift
"
:
[
"
x
"
]
})
})
...
@@ -259,10 +277,14 @@ class SongSelect{
...
@@ -259,10 +277,14 @@ class SongSelect{
// Enter, Space, F, J
// Enter, Space, F, J
cancel
:
code
==
27
||
code
==
8
,
cancel
:
code
==
27
||
code
==
8
,
// Esc, Backspace
// Esc, Backspace
left
:
code
==
68
,
left
:
code
==
37
||
code
==
68
,
// Left, D
// Left, D
right
:
code
==
75
right
:
code
==
39
||
code
==
75
,
// Right, K
// Right, K
up
:
code
==
38
,
// Up
down
:
code
==
40
// Down
}
}
if
(
key
.
cancel
&&
event
){
if
(
key
.
cancel
&&
event
){
event
.
preventDefault
()
event
.
preventDefault
()
...
@@ -281,8 +303,10 @@ class SongSelect{
...
@@ -281,8 +303,10 @@ class SongSelect{
if
(
key
.
confirm
){
if
(
key
.
confirm
){
if
(
this
.
selectedDiff
===
0
){
if
(
this
.
selectedDiff
===
0
){
this
.
toSongSelect
()
this
.
toSongSelect
()
}
else
if
(
this
.
selectedDiff
===
1
){
this
.
toOptions
(
1
)
}
else
{
}
else
{
this
.
toLoadSong
(
this
.
selectedDiff
-
1
,
modifiers
.
shift
,
modifiers
.
ctrl
)
this
.
toLoadSong
(
this
.
selectedDiff
-
this
.
diffOptions
.
length
,
modifiers
.
shift
,
modifiers
.
ctrl
)
}
}
}
else
if
(
key
.
cancel
){
}
else
if
(
key
.
cancel
){
this
.
toSongSelect
()
this
.
toSongSelect
()
...
@@ -290,6 +314,8 @@ class SongSelect{
...
@@ -290,6 +314,8 @@ class SongSelect{
this
.
moveToDiff
(
-
1
)
this
.
moveToDiff
(
-
1
)
}
else
if
(
key
.
right
){
}
else
if
(
key
.
right
){
this
.
moveToDiff
(
1
)
this
.
moveToDiff
(
1
)
}
else
if
(
this
.
selectedDiff
===
1
&&
(
key
.
up
||
key
.
down
)){
this
.
toOptions
(
key
.
up
?
-
1
:
1
)
}
}
}
}
}
}
...
@@ -319,20 +345,21 @@ class SongSelect{
...
@@ -319,20 +345,21 @@ class SongSelect{
}
}
}
else
if
(
this
.
state
.
screen
===
"
difficulty
"
){
}
else
if
(
this
.
state
.
screen
===
"
difficulty
"
){
var
moveBy
=
this
.
diffSelMouse
(
mouse
.
x
,
mouse
.
y
)
var
moveBy
=
this
.
diffSelMouse
(
mouse
.
x
,
mouse
.
y
)
if
(
if
(
mouse
.
x
<
55
||
mouse
.
x
>
967
||
mouse
.
y
<
40
||
mouse
.
y
>
540
){
moveBy
===
0
this
.
toSongSelect
()
||
mouse
.
x
<
55
||
mouse
.
x
>
967
}
else
if
(
moveBy
===
0
){
||
mouse
.
y
<
40
||
mouse
.
y
>
540
this
.
selectedDiff
=
0
){
this
.
toSongSelect
()
this
.
toSongSelect
()
}
else
if
(
moveBy
===
5
){
}
else
if
(
moveBy
===
1
){
this
.
toOptions
(
1
)
}
else
if
(
moveBy
===
this
.
diffOptions
.
length
+
4
){
this
.
state
.
ura
=
!
this
.
state
.
ura
this
.
state
.
ura
=
!
this
.
state
.
ura
assets
.
sounds
[
"
ka
"
].
play
()
assets
.
sounds
[
"
ka
"
].
play
()
if
(
this
.
selectedDiff
===
5
&&
!
this
.
state
.
ura
){
if
(
this
.
selectedDiff
===
this
.
diffOptions
.
length
+
4
&&
!
this
.
state
.
ura
){
this
.
state
.
move
=
-
1
this
.
state
.
move
=
-
1
}
}
}
else
if
(
moveBy
!==
null
){
}
else
if
(
moveBy
!==
null
){
this
.
toLoadSong
(
moveBy
-
1
,
shift
,
ctrl
,
touch
)
this
.
toLoadSong
(
moveBy
-
this
.
diffOptions
.
length
,
shift
,
ctrl
,
touch
)
}
}
}
}
}
}
...
@@ -393,12 +420,12 @@ class SongSelect{
...
@@ -393,12 +420,12 @@ class SongSelect{
}
}
diffSelMouse
(
x
,
y
){
diffSelMouse
(
x
,
y
){
if
(
this
.
state
.
locked
===
0
){
if
(
this
.
state
.
locked
===
0
){
if
(
100
<
x
&&
x
<
160
&&
120
<
y
&&
y
<
420
){
if
(
95
<
x
&&
x
<
239
&&
118
<
y
&&
y
<
422
){
return
0
return
Math
.
floor
((
x
-
95
)
/
((
239
-
95
)
/
2
))
}
else
if
(
422
<
x
&&
x
<
922
&&
95
<
y
&&
y
<
524
){
}
else
if
(
422
<
x
&&
x
<
922
&&
95
<
y
&&
y
<
524
){
var
moveBy
=
Math
.
floor
((
x
-
422
)
/
((
922
-
422
)
/
5
))
+
1
var
moveBy
=
Math
.
floor
((
x
-
422
)
/
((
922
-
422
)
/
5
))
+
this
.
diffOptions
.
length
var
currentSong
=
this
.
songs
[
this
.
selectedSong
]
var
currentSong
=
this
.
songs
[
this
.
selectedSong
]
if
(
this
.
state
.
ura
&&
moveBy
===
4
||
currentSong
.
stars
[
moveBy
-
1
]){
if
(
this
.
state
.
ura
&&
moveBy
===
this
.
diffOptions
+
3
||
currentSong
.
stars
[
moveBy
-
this
.
diffOptions
.
length
]){
return
moveBy
return
moveBy
}
}
}
}
...
@@ -451,8 +478,8 @@ class SongSelect{
...
@@ -451,8 +478,8 @@ class SongSelect{
this
.
state
.
locked
=
true
this
.
state
.
locked
=
true
this
.
state
.
moveHover
=
null
this
.
state
.
moveHover
=
null
this
.
state
.
ura
=
0
this
.
state
.
ura
=
0
if
(
this
.
selectedDiff
===
5
){
if
(
this
.
selectedDiff
===
this
.
diffOptions
.
length
+
4
){
this
.
selectedDiff
=
4
this
.
selectedDiff
=
this
.
diffOptions
.
length
+
3
}
}
assets
.
sounds
[
"
don
"
].
play
()
assets
.
sounds
[
"
don
"
].
play
()
...
@@ -497,11 +524,22 @@ class SongSelect{
...
@@ -497,11 +524,22 @@ class SongSelect{
assets
.
sounds
[
"
don
"
].
play
()
assets
.
sounds
[
"
don
"
].
play
()
localStorage
[
"
selectedSong
"
]
=
this
.
selectedSong
localStorage
[
"
selectedSong
"
]
=
this
.
selectedSong
localStorage
[
"
selectedDiff
"
]
=
difficulty
+
1
localStorage
[
"
selectedDiff
"
]
=
difficulty
+
this
.
diffOptions
.
length
if
(
difficulty
===
3
&&
this
.
state
.
ura
){
if
(
difficulty
===
3
&&
this
.
state
.
ura
){
difficulty
=
4
difficulty
=
4
}
}
var
autoplay
=
false
var
multiplayer
=
false
if
(
this
.
state
.
options
===
1
){
autoplay
=
true
}
else
if
(
this
.
state
.
options
===
2
){
multiplayer
=
true
}
else
if
(
shift
){
autoplay
=
shift
}
else
{
multiplayer
=
ctrl
}
new
loadSong
({
new
loadSong
({
"
title
"
:
selectedSong
.
title
,
"
title
"
:
selectedSong
.
title
,
...
@@ -510,7 +548,12 @@ class SongSelect{
...
@@ -510,7 +548,12 @@ class SongSelect{
"
category
"
:
selectedSong
.
category
,
"
category
"
:
selectedSong
.
category
,
"
type
"
:
selectedSong
.
type
,
"
type
"
:
selectedSong
.
type
,
"
offset
"
:
selectedSong
.
offset
"
offset
"
:
selectedSong
.
offset
},
shift
,
ctrl
,
touch
)
},
autoplay
,
multiplayer
,
touch
)
}
toOptions
(
moveBy
){
assets
.
sounds
[
"
ka
"
].
play
()
this
.
selectedDiff
=
1
this
.
state
.
options
=
this
.
mod
(
this
.
optionsList
.
length
,
this
.
state
.
options
+
moveBy
)
}
}
toTitleScreen
(){
toTitleScreen
(){
assets
.
sounds
[
"
cancel
"
].
play
()
assets
.
sounds
[
"
cancel
"
].
play
()
...
@@ -745,25 +788,25 @@ class SongSelect{
...
@@ -745,25 +788,25 @@ class SongSelect{
do
{
do
{
if
(
hasUra
&&
this
.
state
.
move
>
0
){
if
(
hasUra
&&
this
.
state
.
move
>
0
){
this
.
selectedDiff
+=
this
.
state
.
move
this
.
selectedDiff
+=
this
.
state
.
move
if
(
this
.
selectedDiff
>
5
){
if
(
this
.
selectedDiff
>
this
.
diffOptions
.
length
+
4
){
this
.
state
.
ura
=
!
this
.
state
.
ura
this
.
state
.
ura
=
!
this
.
state
.
ura
if
(
this
.
state
.
ura
){
if
(
this
.
state
.
ura
){
this
.
selectedDiff
=
previousSelection
===
4
?
5
:
previousSelection
this
.
selectedDiff
=
previousSelection
===
this
.
diffOptions
.
length
+
3
?
this
.
diffOptions
.
length
+
4
:
previousSelection
break
break
}
else
{
}
else
{
this
.
state
.
move
=
-
1
this
.
state
.
move
=
-
1
}
}
}
}
}
else
{
}
else
{
this
.
selectedDiff
=
this
.
mod
(
6
,
this
.
selectedDiff
+
this
.
state
.
move
)
this
.
selectedDiff
=
this
.
mod
(
this
.
diffOptions
.
length
+
5
,
this
.
selectedDiff
+
this
.
state
.
move
)
}
}
}
while
(
}
while
(
this
.
selectedDiff
!==
0
&&
!
currentSong
.
stars
[
this
.
selectedDiff
-
1
]
this
.
selectedDiff
>=
this
.
diffOptions
.
length
&&
!
currentSong
.
stars
[
this
.
selectedDiff
-
this
.
diffOptions
.
length
]
||
this
.
selectedDiff
===
4
&&
this
.
state
.
ura
||
this
.
selectedDiff
===
this
.
diffOptions
.
length
+
3
&&
this
.
state
.
ura
||
this
.
selectedDiff
===
5
&&
!
this
.
state
.
ura
||
this
.
selectedDiff
===
this
.
diffOptions
.
length
+
4
&&
!
this
.
state
.
ura
)
)
this
.
state
.
move
=
0
this
.
state
.
move
=
0
}
else
if
(
!
currentSong
.
stars
[
this
.
selectedDiff
-
1
]){
}
else
if
(
this
.
selectedDiff
<
0
||
this
.
selectedDiff
>=
this
.
diffOptions
.
length
&&
!
currentSong
.
stars
[
this
.
selectedDiff
-
this
.
diffOptions
.
length
]){
this
.
selectedDiff
=
0
this
.
selectedDiff
=
0
}
}
}
}
...
@@ -897,9 +940,11 @@ class SongSelect{
...
@@ -897,9 +940,11 @@ class SongSelect{
})
})
var
opened
=
1
var
opened
=
1
var
songSel
=
false
var
songSel
=
false
var
_x
=
x
+
62
for
(
var
i
=
0
;
i
<
this
.
diffOptions
.
length
;
i
++
){
var
_x
=
x
+
62
+
i
*
72
var
_y
=
y
+
67
var
_y
=
y
+
67
ctx
.
fillStyle
=
"
#efb058
"
ctx
.
fillStyle
=
this
.
diffOptions
[
i
].
fill
ctx
.
lineWidth
=
5
ctx
.
lineWidth
=
5
this
.
draw
.
roundedRect
({
this
.
draw
.
roundedRect
({
ctx
:
ctx
,
ctx
:
ctx
,
...
@@ -911,19 +956,25 @@ class SongSelect{
...
@@ -911,19 +956,25 @@ class SongSelect{
})
})
ctx
.
fill
()
ctx
.
fill
()
ctx
.
stroke
()
ctx
.
stroke
()
ctx
.
fillStyle
=
"
#f7d39c
"
ctx
.
fillStyle
=
this
.
diffOptions
[
i
].
iconFill
ctx
.
beginPath
()
ctx
.
beginPath
()
ctx
.
arc
(
_x
,
_y
+
28
,
20
,
0
,
Math
.
PI
*
2
)
ctx
.
arc
(
_x
,
_y
+
28
,
20
,
0
,
Math
.
PI
*
2
)
ctx
.
fill
()
ctx
.
fill
()
this
.
draw
.
diffOptionsIcon
({
this
.
draw
.
diffOptionsIcon
({
ctx
:
ctx
,
ctx
:
ctx
,
x
:
_x
,
x
:
_x
,
y
:
_y
+
28
y
:
_y
+
28
,
iconName
:
this
.
diffOptions
[
i
].
iconName
})
})
var
text
=
this
.
diffOptions
[
i
].
text
if
(
this
.
diffOptions
[
i
].
iconName
===
"
options
"
&&
(
this
.
selectedDiff
===
i
||
this
.
state
.
options
!==
0
)){
text
=
this
.
optionsList
[
this
.
state
.
options
]
}
this
.
draw
.
verticalText
({
this
.
draw
.
verticalText
({
ctx
:
ctx
,
ctx
:
ctx
,
text
:
"
もどる
"
,
text
:
text
,
x
:
_x
,
x
:
_x
,
y
:
_y
+
57
,
y
:
_y
+
57
,
width
:
56
,
width
:
56
,
...
@@ -934,12 +985,13 @@ class SongSelect{
...
@@ -934,12 +985,13 @@ class SongSelect{
letterBorder
:
4
,
letterBorder
:
4
,
fontSize
:
28
,
fontSize
:
28
,
fontFamily
:
this
.
font
,
fontFamily
:
this
.
font
,
letterSpacing
:
4
letterSpacing
:
this
.
diffOptions
[
i
].
letterSpacing
})
})
var
highlight
=
0
var
highlight
=
0
if
(
this
.
state
.
moveHover
===
0
){
if
(
this
.
state
.
moveHover
===
i
){
highlight
=
2
highlight
=
2
}
else
if
(
this
.
selectedDiff
===
0
){
}
else
if
(
this
.
selectedDiff
===
i
){
highlight
=
1
highlight
=
1
}
}
if
(
highlight
){
if
(
highlight
){
...
@@ -954,7 +1006,7 @@ class SongSelect{
...
@@ -954,7 +1006,7 @@ class SongSelect{
opacity
:
highlight
===
2
?
0.8
:
1
,
opacity
:
highlight
===
2
?
0.8
:
1
,
radius
:
24
radius
:
24
})
})
if
(
this
.
selectedDiff
===
0
){
if
(
this
.
selectedDiff
===
i
&&
!
this
.
touchEnabled
){
this
.
draw
.
diffCursor
({
this
.
draw
.
diffCursor
({
ctx
:
ctx
,
ctx
:
ctx
,
font
:
this
.
font
,
font
:
this
.
font
,
...
@@ -964,6 +1016,7 @@ class SongSelect{
...
@@ -964,6 +1016,7 @@ class SongSelect{
}
}
}
}
}
}
}
var
drawDifficulty
=
(
ctx
,
i
,
currentUra
)
=>
{
var
drawDifficulty
=
(
ctx
,
i
,
currentUra
)
=>
{
if
(
currentSong
.
stars
[
i
]
||
currentUra
){
if
(
currentSong
.
stars
[
i
]
||
currentUra
){
if
(
songSel
){
if
(
songSel
){
...
@@ -1057,8 +1110,8 @@ class SongSelect{
...
@@ -1057,8 +1110,8 @@ class SongSelect{
})
})
}
}
}
}
var
currentDiff
=
this
.
selectedDiff
-
1
var
currentDiff
=
this
.
selectedDiff
-
this
.
diffOptions
.
length
if
(
this
.
selectedDiff
===
5
){
if
(
this
.
selectedDiff
===
4
+
this
.
diffOptions
.
length
){
currentDiff
=
3
currentDiff
=
3
}
}
if
(
i
===
currentSong
.
p2Cursor
){
if
(
i
===
currentSong
.
p2Cursor
){
...
@@ -1074,12 +1127,12 @@ class SongSelect{
...
@@ -1074,12 +1127,12 @@ class SongSelect{
}
}
if
(
!
songSel
){
if
(
!
songSel
){
var
highlight
=
0
var
highlight
=
0
if
(
this
.
state
.
moveHover
-
1
===
i
){
if
(
this
.
state
.
moveHover
-
this
.
diffOptions
.
length
===
i
){
highlight
=
2
highlight
=
2
}
else
if
(
currentDiff
===
i
){
}
else
if
(
currentDiff
===
i
){
highlight
=
1
highlight
=
1
}
}
if
(
currentDiff
===
i
){
if
(
currentDiff
===
i
&&
!
this
.
touchEnabled
){
this
.
draw
.
diffCursor
({
this
.
draw
.
diffCursor
({
ctx
:
ctx
,
ctx
:
ctx
,
font
:
this
.
font
,
font
:
this
.
font
,
...
...
public/src/js/view.js
View file @
5a115040
class
View
{
class
View
{
constructor
(
controller
,
bg
,
songTitle
,
songDifficulty
){
constructor
(
controller
){
this
.
controller
=
controller
this
.
controller
=
controller
this
.
bg
=
bg
this
.
songTitle
=
songTitle
this
.
canvas
=
document
.
getElementById
(
"
canvas
"
)
this
.
songDifficulty
=
songDifficulty
this
.
ctx
=
this
.
canvas
.
getContext
(
"
2d
"
)
this
.
pauseMenu
=
document
.
getElementById
(
"
pause-menu
"
)
this
.
pauseMenu
=
document
.
getElementById
(
"
pause-menu
"
)
this
.
cursor
=
document
.
getElementById
(
"
cursor
"
)
this
.
cursor
=
document
.
getElementById
(
"
cursor
"
)
this
.
gameDiv
=
document
.
getElementById
(
"
game
"
)
this
.
gameDiv
=
document
.
getElementById
(
"
game
"
)
var
docW
=
document
.
body
.
offsetWidth
this
.
portraitClass
=
false
var
docH
=
document
.
body
.
offsetHeight
this
.
touchp2Class
=
false
if
(
this
.
controller
.
multiplayer
===
2
){
this
.
canvas
=
new
ScalableCanvas
(
"
canvas-p2
"
,
docW
,
docH
/
3
*
2
)
this
.
currentScore
=
{
this
.
canvas
.
canvas
.
style
.
position
=
"
absolute
"
ms
:
-
Infinity
,
this
.
canvas
.
canvas
.
style
.
top
=
"
33%
"
type
:
0
this
.
gameDiv
.
appendChild
(
this
.
canvas
.
canvas
)
}
else
{
this
.
canvas
=
new
ScalableCanvas
(
"
canvas
"
,
docW
,
docH
)
}
}
this
.
winW
=
this
.
canvas
.
scaledWidth
this
.
noteFace
=
{
this
.
winH
=
this
.
canvas
.
scaledHeight
small
:
0
,
if
(
this
.
controller
.
multiplayer
===
2
){
big
:
3
this
.
winH
=
this
.
winH
/
2
*
3
}
}
this
.
ctx
=
this
.
canvas
.
ctx
this
.
taikoSquareW
=
this
.
winW
/
4
this
.
slotX
=
this
.
taikoSquareW
+
100
this
.
currentScore
=
0
this
.
special
=
""
this
.
scoreDispCount
=
-
1
this
.
scoreOpacity
=
1
this
.
lastMeasure
=
0
this
.
currentTimingPoint
=
0
//Distance to be done by the circle
this
.
distanceForCircle
=
this
.
winW
-
this
.
slotX
this
.
currentCircleFace
=
0
this
.
currentDonFace
=
0
this
.
currentBigDonFace
=
1
this
.
nextBeat
=
0
this
.
nextBeat
=
0
this
.
gogoTime
=
0
this
.
gogoTime
=
0
this
.
gogoTimeStarted
=
-
Infinity
this
.
drumroll
=
[]
this
.
drumroll
=
[]
this
.
beatInterval
=
this
.
controller
.
parsedSongData
.
beatInfo
.
beatInterval
this
.
beatInterval
=
this
.
controller
.
parsedSongData
.
beatInfo
.
beatInterval
this
.
font
=
"
TnT, Meiryo, sans-serif
"
this
.
draw
=
new
CanvasDraw
()
this
.
assets
=
new
ViewAssets
(
this
)
this
.
assets
=
new
ViewAssets
(
this
)
this
.
titleCache
=
new
CanvasCache
()
this
.
comboCache
=
new
CanvasCache
()
this
.
multiplayer
=
this
.
controller
.
multiplayer
this
.
touchEnabled
=
this
.
controller
.
touchEnabled
this
.
touch
=
-
Infinity
this
.
touch
=
-
Infinity
if
(
this
.
controller
.
touchEnabled
){
if
(
this
.
multiplayer
!==
2
){
this
.
touchEnabled
=
true
pageEvents
.
add
(
window
,
"
resize
"
,
()
=>
{
if
(
this
.
controller
.
game
.
isPaused
()){
this
.
refresh
()
setTimeout
(
this
.
refresh
.
bind
(
this
),
100
)
}
})
if
(
this
.
controller
.
touchEnabled
){
this
.
touchDrumDiv
=
document
.
getElementById
(
"
touch-drum
"
)
this
.
touchDrumDiv
=
document
.
getElementById
(
"
touch-drum
"
)
this
.
touchDrumImg
=
document
.
getElementById
(
"
touch-drum-img
"
)
this
.
touchDrumImg
=
document
.
getElementById
(
"
touch-drum-img
"
)
this
.
gameDiv
.
classList
.
add
(
"
touch-visible
"
)
this
.
gameDiv
.
classList
.
add
(
"
touch-visible
"
)
document
.
getElementById
(
"
version
"
).
classList
.
add
(
"
version-hide
"
)
document
.
getElementById
(
"
version
"
).
classList
.
add
(
"
version-hide
"
)
pageEvents
.
add
(
this
.
canva
s
.
canvas
,
"
touchstart
"
,
this
.
ontouch
.
bind
(
this
))
pageEvents
.
add
(
thi
s
.
canvas
,
"
touchstart
"
,
this
.
ontouch
.
bind
(
this
))
this
.
touchFullBtn
=
document
.
getElementById
(
"
touch-full-btn
"
)
this
.
touchFullBtn
=
document
.
getElementById
(
"
touch-full-btn
"
)
pageEvents
.
add
(
this
.
touchFullBtn
,
"
touchend
"
,
toggleFullscreen
)
pageEvents
.
add
(
this
.
touchFullBtn
,
"
touchend
"
,
toggleFullscreen
)
...
@@ -73,103 +64,447 @@ class View{
...
@@ -73,103 +64,447 @@ class View{
pageEvents
.
add
(
this
.
touchPauseBtn
,
"
touchend
"
,
()
=>
{
pageEvents
.
add
(
this
.
touchPauseBtn
,
"
touchend
"
,
()
=>
{
this
.
controller
.
togglePauseMenu
()
this
.
controller
.
togglePauseMenu
()
})
})
if
(
this
.
multiplayer
){
this
.
touchPauseBtn
.
style
.
display
=
"
none
"
}
}
}
}
}
}
run
(){
run
(){
this
.
ctx
.
font
=
"
normal 14pt TnT, Meiryo, sans-serif
"
this
.
setBackground
()
this
.
setBackground
()
if
(
this
.
controller
.
multiplayer
!==
2
){
var
gameSong
=
document
.
getElementsByClassName
(
"
game-song
"
)[
0
]
gameSong
.
appendChild
(
document
.
createTextNode
(
this
.
songTitle
))
gameSong
.
setAttribute
(
"
alt
"
,
this
.
songTitle
)
}
this
.
lastMousemove
=
this
.
controller
.
getElapsedTime
()
this
.
lastMousemove
=
this
.
controller
.
getElapsedTime
()
pageEvents
.
mouseAdd
(
this
,
this
.
onmousemove
.
bind
(
this
))
pageEvents
.
mouseAdd
(
this
,
this
.
onmousemove
.
bind
(
this
))
this
.
refresh
()
this
.
refresh
()
}
}
setBackground
(){
refresh
(){
var
gameDiv
=
document
.
getElementById
(
"
game
"
)
var
ctx
=
this
.
ctx
var
selectedSong
=
this
.
controller
.
selectedSong
if
(
selectedSong
.
defaultBg
){
var
winW
=
innerWidth
var
categories
=
{
var
winH
=
lastHeight
"
J-POP
"
:
0
,
"
アニメ
"
:
1
,
if
(
winW
/
32
>
winH
/
9
){
"
ボーカロイド™曲
"
:
2
,
winW
=
winH
/
9
*
32
"
バラエティ
"
:
3
,
"
クラシック
"
:
4
,
"
ゲームミュージック
"
:
5
,
"
ナムコオリジナル
"
:
6
}
}
var
catId
=
7
if
(
selectedSong
.
category
in
categories
){
this
.
portrait
=
winW
<
winH
catId
=
categories
[
selectedSong
.
category
]
var
touchMultiplayer
=
this
.
touchEnabled
&&
this
.
multiplayer
&&
!
this
.
portrait
this
.
pixelRatio
=
window
.
devicePixelRatio
||
1
winW
*=
this
.
pixelRatio
winH
*=
this
.
pixelRatio
if
(
this
.
portrait
){
var
ratioX
=
winW
/
720
var
ratioY
=
winH
/
1280
}
else
{
var
ratioX
=
winW
/
1280
var
ratioY
=
winH
/
720
}
}
this
.
bg
=
assets
.
image
[
"
bg_genre_
"
+
catId
].
src
var
ratio
=
(
ratioX
<
ratioY
?
ratioX
:
ratioY
)
gameDiv
.
classList
.
add
(
"
default-bg
"
)
if
(
this
.
winW
!==
winW
||
this
.
winH
!==
winH
){
this
.
winW
=
winW
this
.
winH
=
winH
this
.
ratio
=
ratio
if
(
this
.
multiplayer
!==
2
){
this
.
canvas
.
width
=
winW
this
.
canvas
.
height
=
winH
ctx
.
scale
(
ratio
,
ratio
)
this
.
canvas
.
style
.
width
=
(
winW
/
this
.
pixelRatio
)
+
"
px
"
this
.
canvas
.
style
.
height
=
(
winH
/
this
.
pixelRatio
)
+
"
px
"
this
.
titleCache
.
resize
(
640
,
80
,
ratio
)
}
this
.
fillComboCache
()
}
else
if
(
this
.
multiplayer
!==
2
){
ctx
.
clearRect
(
0
,
0
,
winW
/
ratio
,
winH
/
ratio
)
}
winW
/=
ratio
winH
/=
ratio
var
ms
=
this
.
getMS
()
if
(
this
.
portrait
){
var
frameTop
=
winH
/
2
-
1280
/
2
var
frameLeft
=
winW
/
2
-
720
/
2
}
else
{
var
frameTop
=
winH
/
2
-
720
/
2
var
frameLeft
=
winW
/
2
-
1280
/
2
}
if
(
this
.
multiplayer
===
2
){
frameTop
+=
this
.
multiplayer
===
2
?
165
:
176
}
if
(
touchMultiplayer
){
if
(
!
this
.
touchp2Class
){
this
.
touchp2Class
=
true
this
.
gameDiv
.
classList
.
add
(
"
touchp2
"
)
}
frameTop
-=
90
}
else
if
(
this
.
touchp2Class
){
this
.
touchp2Class
=
false
this
.
gameDiv
.
classList
.
remove
(
"
touchp2
"
)
}
ctx
.
save
()
ctx
.
translate
(
0
,
frameTop
)
this
.
drawGogoTime
()
if
(
!
touchMultiplayer
){
this
.
assets
.
drawAssets
(
"
background
"
)
}
if
(
this
.
multiplayer
!==
2
){
this
.
titleCache
.
get
({
ctx
:
ctx
,
x
:
winW
-
(
touchMultiplayer
&&
fullScreenSupported
?
750
:
650
),
y
:
touchMultiplayer
?
75
:
10
,
w
:
640
,
h
:
80
,
id
:
"
title
"
},
ctx
=>
{
this
.
draw
.
layeredText
({
ctx
:
ctx
,
text
:
this
.
controller
.
selectedSong
.
title
,
fontSize
:
40
,
fontFamily
:
this
.
font
,
x
:
620
,
y
:
20
,
width
:
600
,
align
:
"
right
"
},
[
{
outline
:
"
#000
"
,
letterBorder
:
10
},
{
fill
:
"
#fff
"
}
])
})
}
var
score
=
this
.
controller
.
getGlobalScore
()
var
gaugePercent
=
Math
.
round
(
score
.
gauge
/
2
)
/
50
if
(
this
.
multiplayer
===
2
){
var
scoreImg
=
"
bg_score_p2
"
var
scoreFill
=
"
#6bbec0
"
}
else
{
var
scoreImg
=
"
bg_score_p1
"
var
scoreFill
=
"
#fa4529
"
}
if
(
this
.
portrait
){
// Portrait
if
(
!
this
.
portraitClass
){
this
.
portraitClass
=
true
this
.
gameDiv
.
classList
.
add
(
"
portrait
"
)
}
this
.
slotPos
=
{
x
:
66
,
y
:
frameTop
+
375
,
size
:
100
,
paddingLeft
:
0
}
this
.
scorePos
=
{
x
:
363
,
y
:
frameTop
+
(
this
.
multiplayer
===
2
?
520
:
227
)}
var
animPos
=
{
x1
:
this
.
slotPos
.
x
+
13
,
y1
:
this
.
slotPos
.
y
+
(
this
.
multiplayer
===
2
?
27
:
-
27
),
x2
:
winW
-
38
,
y2
:
frameTop
+
(
this
.
multiplayer
===
2
?
484
:
293
)
}
var
taikoPos
=
{
x
:
19
,
y
:
frameTop
+
(
this
.
multiplayer
===
2
?
464
:
184
),
w
:
111
,
h
:
130
}
ctx
.
fillStyle
=
"
#000
"
ctx
.
fillRect
(
0
,
this
.
multiplayer
===
2
?
306
:
288
,
winW
,
this
.
multiplayer
===
1
?
184
:
183
)
ctx
.
beginPath
()
if
(
this
.
multiplayer
===
2
){
ctx
.
moveTo
(
0
,
467
)
ctx
.
lineTo
(
384
,
467
)
ctx
.
lineTo
(
384
,
512
)
ctx
.
lineTo
(
184
,
560
)
ctx
.
lineTo
(
0
,
560
)
}
else
{
ctx
.
moveTo
(
0
,
217
)
ctx
.
lineTo
(
184
,
217
)
ctx
.
lineTo
(
384
,
265
)
ctx
.
lineTo
(
384
,
309
)
ctx
.
lineTo
(
0
,
309
)
}
ctx
.
fill
()
// Left side
ctx
.
fillStyle
=
scoreFill
var
leftSide
=
(
ctx
,
mul
)
=>
{
ctx
.
beginPath
()
if
(
this
.
multiplayer
===
2
){
ctx
.
moveTo
(
0
,
468
*
mul
)
ctx
.
lineTo
(
380
*
mul
,
468
*
mul
)
ctx
.
lineTo
(
380
*
mul
,
512
*
mul
)
ctx
.
lineTo
(
184
*
mul
,
556
*
mul
)
ctx
.
lineTo
(
0
,
556
*
mul
)
}
else
{
ctx
.
moveTo
(
0
,
221
*
mul
)
ctx
.
lineTo
(
184
*
mul
,
221
*
mul
)
ctx
.
lineTo
(
380
*
mul
,
265
*
mul
)
ctx
.
lineTo
(
380
*
mul
,
309
*
mul
)
ctx
.
lineTo
(
0
,
309
*
mul
)
}
}
leftSide
(
ctx
,
1
)
ctx
.
fill
()
ctx
.
globalAlpha
=
0.5
this
.
draw
.
pattern
({
ctx
:
ctx
,
img
:
assets
.
image
[
scoreImg
],
shape
:
leftSide
,
dx
:
0
,
dy
:
45
,
scale
:
1.55
})
ctx
.
globalAlpha
=
1
// Score background
ctx
.
fillStyle
=
"
#000
"
ctx
.
beginPath
()
if
(
this
.
multiplayer
===
2
){
this
.
draw
.
roundedCorner
(
ctx
,
184
,
512
,
20
,
0
)
ctx
.
lineTo
(
384
,
512
)
this
.
draw
.
roundedCorner
(
ctx
,
384
,
560
,
12
,
2
)
ctx
.
lineTo
(
184
,
560
)
}
else
{
ctx
.
moveTo
(
184
,
217
)
this
.
draw
.
roundedCorner
(
ctx
,
384
,
217
,
12
,
1
)
ctx
.
lineTo
(
384
,
265
)
this
.
draw
.
roundedCorner
(
ctx
,
184
,
265
,
20
,
3
)
}
ctx
.
fill
()
// Difficulty
var
badgeImg
=
assets
.
image
[
"
muzu_
"
+
this
.
controller
.
selectedSong
.
difficulty
]
var
badgeW
=
badgeImg
.
width
/
badgeImg
.
height
*
53
ctx
.
drawImage
(
badgeImg
,
157
-
badgeW
/
2
,
this
.
multiplayer
===
2
?
497
:
228
,
badgeW
,
53
)
// Badges
if
(
this
.
controller
.
autoPlayEnabled
&&
!
this
.
controller
.
multiplayer
){
this
.
ctx
.
drawImage
(
assets
.
image
[
"
badge_auto
"
],
183
,
this
.
multiplayer
===
2
?
490
:
265
,
23
,
23
)
}
// Gauge
ctx
.
fillStyle
=
"
#000
"
ctx
.
beginPath
()
var
gaugeX
=
winW
-
788
*
0.7
-
32
if
(
this
.
multiplayer
===
2
){
ctx
.
moveTo
(
gaugeX
,
464
)
ctx
.
lineTo
(
winW
,
464
)
ctx
.
lineTo
(
winW
,
489
)
this
.
draw
.
roundedCorner
(
ctx
,
gaugeX
,
489
,
12
,
3
)
}
else
{
this
.
draw
.
roundedCorner
(
ctx
,
gaugeX
,
288
,
12
,
0
)
ctx
.
lineTo
(
winW
,
288
)
ctx
.
lineTo
(
winW
,
314
)
ctx
.
lineTo
(
gaugeX
,
314
)
}
ctx
.
fill
()
this
.
draw
.
gauge
({
ctx
:
ctx
,
x
:
winW
,
y
:
this
.
multiplayer
===
2
?
468
:
273
,
clear
:
25
/
50
,
percentage
:
gaugePercent
,
font
:
this
.
font
,
scale
:
0.7
,
multiplayer
:
this
.
multiplayer
===
2
})
this
.
draw
.
soul
({
ctx
:
ctx
,
x
:
winW
-
40
,
y
:
this
.
multiplayer
===
2
?
484
:
293
,
scale
:
0.75
,
cleared
:
gaugePercent
-
1
/
50
>=
25
/
50
})
// Note bar
ctx
.
fillStyle
=
"
#2c2a2c
"
ctx
.
fillRect
(
0
,
314
,
winW
,
122
)
ctx
.
fillStyle
=
"
#847f84
"
ctx
.
fillRect
(
0
,
440
,
winW
,
24
)
}
else
{
// Landscape
if
(
this
.
portraitClass
){
this
.
portraitClass
=
false
this
.
gameDiv
.
classList
.
remove
(
"
portrait
"
)
}
this
.
slotPos
=
{
x
:
413
,
y
:
frameTop
+
257
,
size
:
106
,
paddingLeft
:
332
}
this
.
scorePos
=
{
x
:
155
,
y
:
frameTop
+
(
this
.
multiplayer
===
2
?
318
:
193
)
}
var
animPos
=
{
x1
:
this
.
slotPos
.
x
+
14
,
y1
:
this
.
slotPos
.
y
+
(
this
.
multiplayer
===
2
?
29
:
-
29
),
x2
:
winW
-
55
,
y2
:
frameTop
+
(
this
.
multiplayer
===
2
?
378
:
165
)
}
var
taikoPos
=
{
x
:
179
,
y
:
frameTop
+
190
,
w
:
138
,
h
:
162
}
ctx
.
fillStyle
=
"
#000
"
ctx
.
fillRect
(
0
,
184
,
winW
,
this
.
multiplayer
===
1
?
177
:
176
)
ctx
.
beginPath
()
if
(
this
.
multiplayer
===
2
){
ctx
.
moveTo
(
328
,
351
)
ctx
.
lineTo
(
winW
,
351
)
ctx
.
lineTo
(
winW
,
385
)
this
.
draw
.
roundedCorner
(
ctx
,
328
,
385
,
10
,
3
)
}
else
{
ctx
.
moveTo
(
328
,
192
)
this
.
draw
.
roundedCorner
(
ctx
,
328
,
158
,
10
,
0
)
ctx
.
lineTo
(
winW
,
158
)
ctx
.
lineTo
(
winW
,
192
)
}
ctx
.
fill
()
// Gauge
this
.
draw
.
gauge
({
ctx
:
ctx
,
x
:
winW
,
y
:
this
.
multiplayer
===
2
?
357
:
135
,
clear
:
25
/
50
,
percentage
:
gaugePercent
,
font
:
this
.
font
,
multiplayer
:
this
.
multiplayer
===
2
})
this
.
draw
.
soul
({
ctx
:
ctx
,
x
:
winW
-
57
,
y
:
this
.
multiplayer
===
2
?
378
:
165
,
cleared
:
gaugePercent
-
1
/
50
>=
25
/
50
})
// Note bar
ctx
.
fillStyle
=
"
#2c2a2c
"
ctx
.
fillRect
(
332
,
192
,
winW
-
332
,
130
)
ctx
.
fillStyle
=
"
#847f84
"
ctx
.
fillRect
(
332
,
326
,
winW
-
332
,
26
)
// Left side
ctx
.
fillStyle
=
scoreFill
ctx
.
fillRect
(
0
,
192
,
328
,
160
)
ctx
.
globalAlpha
=
0.5
this
.
draw
.
pattern
({
ctx
:
ctx
,
img
:
assets
.
image
[
scoreImg
],
x
:
0
,
y
:
192
,
w
:
328
,
h
:
160
,
dx
:
0
,
dy
:
45
,
scale
:
1.55
})
ctx
.
globalAlpha
=
1
// Difficulty
var
badgeImg
=
assets
.
image
[
"
muzu_
"
+
this
.
controller
.
selectedSong
.
difficulty
]
var
badgeW
=
badgeImg
.
width
/
badgeImg
.
height
*
120
ctx
.
drawImage
(
badgeImg
,
87
-
badgeW
/
2
,
this
.
multiplayer
===
2
?
194
:
232
,
badgeW
,
120
)
// Badges
if
(
this
.
controller
.
autoPlayEnabled
&&
!
this
.
controller
.
multiplayer
){
this
.
ctx
.
drawImage
(
assets
.
image
[
"
badge_auto
"
],
125
,
235
,
34
,
34
)
}
}
gameDiv
.
style
.
backgroundImage
=
"
url('
"
+
this
.
bg
+
"
')
"
}
// Score background
positionning
(){
ctx
.
fillStyle
=
"
#000
"
var
docW
=
document
.
body
.
offsetWidth
ctx
.
beginPath
()
var
docH
=
document
.
body
.
offsetHeight
if
(
this
.
multiplayer
===
2
){
this
.
canvas
.
rescale
()
ctx
.
moveTo
(
0
,
312
)
if
(
this
.
controller
.
multiplayer
===
2
){
this
.
draw
.
roundedCorner
(
ctx
,
176
,
312
,
20
,
1
)
docH
=
docH
/
3
*
2
ctx
.
lineTo
(
176
,
353
)
}
ctx
.
lineTo
(
0
,
353
)
this
.
canvas
.
resize
(
docW
,
docH
)
this
.
winW
=
this
.
canvas
.
scaledWidth
this
.
winH
=
this
.
canvas
.
scaledHeight
if
(
this
.
controller
.
multiplayer
===
2
){
this
.
winH
=
this
.
winH
/
2
*
3
}
this
.
barY
=
0.25
*
this
.
winH
this
.
barH
=
0.23
*
this
.
winH
this
.
lyricsBarH
=
0.2
*
this
.
barH
this
.
taikoSquareW
=
this
.
winW
/
4
this
.
taikoH
=
this
.
barH
this
.
taikoW
=
this
.
taikoH
/
1.2
this
.
taikoX
=
this
.
taikoSquareW
*
0.76
-
this
.
taikoW
/
2
this
.
taikoY
=
this
.
barY
+
5
this
.
slotX
=
this
.
taikoSquareW
+
this
.
barH
*
0.5
this
.
scoreSquareW
=
this
.
taikoSquareW
*
0.55
this
.
scoreSquareH
=
this
.
barH
*
0.25
this
.
circleSize
=
this
.
barH
*
0.18
this
.
bigCircleSize
=
this
.
circleSize
*
(
5
/
3
)
this
.
circleY
=
this
.
barY
+
(
this
.
barH
-
this
.
lyricsBarH
)
/
2
this
.
lyricsSize
=
this
.
lyricsBarH
*
0.6
var
HPBarRatio
=
703
/
51
this
.
HPBarW
=
this
.
taikoSquareW
*
2.475
this
.
HPBarH
=
this
.
barH
*
0.35
if
(
this
.
HPBarW
/
this
.
HPBarH
>
HPBarRatio
){
this
.
HPBarW
=
this
.
HPBarH
*
HPBarRatio
}
else
{
}
else
{
this
.
HPBarH
=
this
.
HPBarW
/
HPBarRatio
ctx
.
moveTo
(
0
,
191
)
}
ctx
.
lineTo
(
176
,
191
)
this
.
HPBarX
=
this
.
winW
-
this
.
HPBarW
this
.
draw
.
roundedCorner
(
ctx
,
176
,
232
,
20
,
2
)
this
.
HPBarY
=
this
.
barY
-
this
.
HPBarH
ctx
.
lineTo
(
0
,
232
)
this
.
HPbarColX
=
this
.
HPBarX
+
this
.
HPBarW
*
0.008
}
this
.
HPbarColY
=
this
.
HPBarY
+
this
.
HPBarH
*
0.14
ctx
.
fill
()
this
.
HPBarColMaxW
=
this
.
HPBarW
*
0.925
}
this
.
HPBarColH
=
this
.
HPBarH
*
0.8
var
diffRatio
=
176
/
120
ctx
.
restore
()
this
.
diffH
=
this
.
winH
*
0.16
this
.
diffW
=
this
.
diffH
*
diffRatio
animPos
.
w
=
animPos
.
x2
-
animPos
.
x1
this
.
diffX
=
this
.
taikoX
*
0.10
animPos
.
h
=
animPos
.
y1
-
animPos
.
y2
this
.
diffY
=
this
.
taikoY
*
1.05
+
this
.
taikoH
*
0.19
this
.
animateBezier
=
[{
// 427, 228
x
:
animPos
.
x1
,
y
:
animPos
.
y1
},
{
// 560, 10
x
:
animPos
.
x1
+
animPos
.
w
/
6
,
y
:
animPos
.
y1
-
animPos
.
h
*
(
this
.
multiplayer
===
2
?
2.5
:
3.5
)
},
{
// 940, -150
x
:
animPos
.
x2
-
animPos
.
w
/
3
,
y
:
animPos
.
y2
-
animPos
.
h
*
(
this
.
multiplayer
===
2
?
3.5
:
5
)
},
{
// 1225, 165
x
:
animPos
.
x2
,
y
:
animPos
.
y2
}]
var
touchTop
=
frameTop
+
(
touchMultiplayer
?
135
:
0
)
this
.
touchDrum
=
(()
=>
{
this
.
touchDrum
=
(()
=>
{
var
sw
=
842
var
sw
=
842
var
sh
=
340
var
sh
=
340
var
x
=
0
var
x
=
0
var
y
=
this
.
barY
+
this
.
barH
+
5
var
y
=
this
.
portrait
?
touchTop
+
477
:
touchTop
+
36
5
var
paddingTop
=
this
.
barH
*
0.1
var
paddingTop
=
13
var
w
=
this
.
winW
var
w
=
winW
var
maxH
=
this
.
winH
-
(
this
.
barY
+
this
.
barH
+
5
)
var
maxH
=
winH
-
y
var
h
=
maxH
-
paddingTop
var
h
=
maxH
-
paddingTop
if
(
w
/
h
>=
sw
/
sh
){
if
(
w
/
h
>=
sw
/
sh
){
w
=
h
/
sh
*
sw
w
=
h
/
sh
*
sw
x
=
(
this
.
winW
-
w
)
/
2
x
=
(
winW
-
w
)
/
2
y
+=
paddingTop
y
+=
paddingTop
}
else
{
}
else
{
h
=
w
/
sw
*
sh
h
=
w
/
sw
*
sh
...
@@ -179,326 +514,316 @@ class View{
...
@@ -179,326 +514,316 @@ class View{
x
:
x
,
y
:
y
,
w
:
w
,
h
:
h
x
:
x
,
y
:
y
,
w
:
w
,
h
:
h
}
}
})()
})()
this
.
touchCircle
=
(()
=>
{
this
.
touchCircle
=
{
return
{
x
:
winW
/
2
,
x
:
this
.
winW
/
2
,
y
:
winH
+
this
.
touchDrum
.
h
*
0.1
,
y
:
this
.
winH
+
this
.
touchDrum
.
h
*
0.1
,
rx
:
this
.
touchDrum
.
w
/
2
-
this
.
touchDrum
.
h
*
0.03
,
rx
:
this
.
touchDrum
.
w
/
2
-
this
.
touchDrum
.
h
*
0.03
,
ry
:
this
.
touchDrum
.
h
*
1.07
ry
:
this
.
touchDrum
.
h
*
1.07
}
}
})()
if
(
this
.
multiplayer
!==
2
){
this
.
mouseIdle
()
this
.
drawTouch
()
}
}
refresh
(){
this
.
positionning
()
this
.
distanceForCircle
=
this
.
winW
-
this
.
slotX
this
.
ctx
.
clearRect
(
0
,
0
,
this
.
canvas
.
scaledWidth
,
this
.
canvas
.
scaledHeight
)
// Score
ctx
.
save
()
ctx
.
font
=
"
30px
"
+
this
.
font
ctx
.
fillStyle
=
"
#fff
"
ctx
.
strokeStyle
=
"
#fff
"
ctx
.
lineWidth
=
0.3
ctx
.
textAlign
=
"
center
"
ctx
.
textBaseline
=
"
top
"
var
glyph
=
29
var
pointsText
=
score
.
points
.
toString
().
split
(
""
)
ctx
.
translate
(
this
.
scorePos
.
x
,
this
.
scorePos
.
y
)
ctx
.
scale
(
0.7
,
1
)
for
(
var
i
in
pointsText
){
var
x
=
glyph
*
(
i
-
pointsText
.
length
+
1
)
ctx
.
strokeText
(
pointsText
[
i
],
x
,
0
)
ctx
.
fillText
(
pointsText
[
i
],
x
,
0
)
}
ctx
.
restore
()
// Draw
// Bar pressed keys
this
.
assets
.
drawAssets
(
"
background
"
)
var
keyTime
=
this
.
controller
.
getKeyTime
()
this
.
drawBar
()
var
sound
=
keyTime
[
"
don
"
]
>
keyTime
[
"
ka
"
]
?
"
don
"
:
"
ka
"
this
.
drawSlot
()
var
padding
=
this
.
slotPos
.
paddingLeft
this
.
drawHPBar
()
var
mul
=
this
.
slotPos
.
size
/
106
this
.
assets
.
drawAssets
(
"
bar
"
)
var
barY
=
this
.
slotPos
.
y
-
65
*
mul
this
.
drawMeasures
()
var
barH
=
130
*
mul
this
.
drawScore
()
this
.
drawCircles
(
this
.
controller
.
getCircles
())
if
(
this
.
gogoTime
||
ms
<=
this
.
gogoTimeStarted
+
100
){
this
.
drawCircles
(
this
.
drumroll
)
var
grd
=
ctx
.
createLinearGradient
(
0
,
0
,
this
.
winW
,
0
)
this
.
drawTaikoSquare
()
grd
.
addColorStop
(
0
,
"
#512a2c
"
)
this
.
drawDifficulty
()
grd
.
addColorStop
(
0.46
,
"
#6f2a2d
"
)
this
.
drawPressedKeys
()
grd
.
addColorStop
(
0.76
,
"
#8a4763
"
)
this
.
drawCombo
()
grd
.
addColorStop
(
1
,
"
#2c2a2c
"
)
this
.
drawGlobalScore
()
ctx
.
fillStyle
=
grd
this
.
updateDonFaces
()
this
.
drawGogoTime
()
this
.
mouseIdle
()
if
(
!
this
.
touchEnabled
){
if
(
!
this
.
touchEnabled
){
this
.
assets
.
drawAssets
(
"
foreground
"
)
var
alpha
=
Math
.
min
(
100
,
ms
-
this
.
gogoTimeStarted
)
/
100
if
(
!
this
.
gogoTime
){
alpha
=
1
-
alpha
}
}
this
.
drawTouch
()
ctx
.
globalAlpha
=
alpha
//this.drawTime()
}
}
updateDonFaces
(){
ctx
.
fillRect
(
padding
,
barY
,
winW
-
padding
,
barH
)
var
ms
=
this
.
controller
.
getElapsedTime
()
while
(
ms
>=
this
.
nextBeat
){
this
.
nextBeat
+=
this
.
beatInterval
if
(
this
.
controller
.
getCombo
()
>=
50
){
var
face
=
Math
.
floor
(
ms
/
this
.
beatInterval
)
%
2
this
.
currentBigDonFace
=
face
this
.
currentDonFace
=
face
}
else
{
this
.
currentBigDonFace
=
1
this
.
currentDonFace
=
0
}
}
if
(
keyTime
[
sound
]
>
ms
-
200
){
var
gradients
=
{
"
don
"
:
[
"
#f54c25
"
,
"
#232323
"
],
"
ka
"
:
[
"
#75cee9
"
,
"
#232323
"
]
}
}
var
grd
=
ctx
.
createLinearGradient
(
0
,
0
,
this
.
winW
,
0
)
grd
.
addColorStop
(
0
,
gradients
[
sound
][
0
])
grd
.
addColorStop
(
1
,
gradients
[
sound
][
1
])
ctx
.
fillStyle
=
grd
ctx
.
globalAlpha
=
1
-
(
ms
-
keyTime
[
sound
])
/
200
ctx
.
fillRect
(
padding
,
barY
,
winW
-
padding
,
barH
)
}
}
drawHPBar
(){
ctx
.
globalAlpha
=
1
var
z
=
this
.
canvas
.
scale
var
bottomSquareX
=
this
.
taikoSquareW
// Taiko
var
borderSize
=
this
.
HPBarH
*
0.2
ctx
.
drawImage
(
assets
.
image
[
"
taiko
"
],
this
.
ctx
.
fillStyle
=
"
#000
"
0
,
0
,
138
,
162
,
this
.
ctx
.
beginPath
()
taikoPos
.
x
,
taikoPos
.
y
,
taikoPos
.
w
,
taikoPos
.
h
// Right hand black square
this
.
ctx
.
fillRect
(
this
.
HPBarX
+
this
.
HPBarW
-
this
.
HPBarY
*
0.2
,
this
.
HPBarY
,
this
.
HPBarW
*
0.2
,
this
.
HPBarH
)
this
.
ctx
.
fillRect
(
bottomSquareX
+
borderSize
,
this
.
HPBarY
+
0.435
*
this
.
HPBarH
,
this
.
winW
-
bottomSquareX
-
borderSize
,
this
.
HPBarH
/
2
+
2
*
z
)
this
.
ctx
.
fillRect
(
bottomSquareX
,
this
.
HPBarY
+
0.68
*
this
.
HPBarH
,
this
.
HPBarW
*
0.8
,
this
.
HPBarH
/
4
+
2
*
z
)
this
.
ctx
.
arc
(
bottomSquareX
+
borderSize
,
this
.
HPBarY
+
0.435
*
this
.
HPBarH
+
borderSize
,
borderSize
,
0
,
Math
.
PI
*
2
)
)
this
.
ctx
.
fill
()
this
.
ctx
.
closePath
()
this
.
ctx
.
fillOpacity
=
0.5
// Taiko pressed keys
this
.
ctx
.
drawImage
(
assets
.
image
[
"
hp-bar-bg
"
],
var
kbd
=
this
.
controller
.
getBindings
()
this
.
HPBarX
,
this
.
HPBarY
,
var
keys
=
[
"
ka_l
"
,
"
ka_r
"
,
"
don_l
"
,
"
don_r
"
]
this
.
HPBarW
,
this
.
HPBarH
)
for
(
var
i
=
0
;
i
<
keys
.
length
;
i
++
){
this
.
ctx
.
fillOpacity
=
1
var
keyMS
=
ms
-
keyTime
[
kbd
[
keys
[
i
]]]
var
hpBar
=
this
.
getHP
()
if
(
keyMS
<
130
){
this
.
ctx
.
drawImage
(
assets
.
image
[
"
hp-bar-colour
"
],
if
(
keyMS
>
70
&&
!
this
.
touchEnabled
){
0
,
0
,
ctx
.
globalAlpha
=
this
.
draw
.
easeOut
(
1
-
(
keyMS
-
70
)
/
60
)
Math
.
max
(
1
,
hpBar
.
imgW
),
40
,
}
this
.
HPbarColX
,
this
.
HPbarColY
,
ctx
.
drawImage
(
assets
.
image
[
"
taiko
"
],
hpBar
.
canvasW
,
this
.
HPBarColH
0
,
162
*
(
i
+
1
),
138
,
162
,
taikoPos
.
x
,
taikoPos
.
y
,
taikoPos
.
w
,
taikoPos
.
h
)
)
}
}
getHP
(){
var
circles
=
this
.
controller
.
getCircles
()
var
currentCircle
=
this
.
controller
.
getCurrentCircle
()
var
gauge
=
this
.
controller
.
getGlobalScore
().
gauge
var
width
=
Math
.
floor
(
gauge
*
650
/
1000
)
*
10
return
{
imgW
:
width
,
canvasW
:
width
/
650
*
this
.
HPBarColMaxW
}
}
}
ctx
.
globalAlpha
=
1
drawMeasures
(){
var
measures
=
this
.
controller
.
parsedSongData
.
measures
// Combo
var
currentTime
=
this
.
controller
.
getElapsedTime
()
var
scoreMS
=
ms
-
this
.
currentScore
.
ms
measures
.
forEach
((
measure
,
index
)
=>
{
var
timeForDistance
=
this
.
posToMs
(
this
.
distanceForCircle
,
measure
.
speed
)
if
(
currentTime
>=
measure
.
ms
-
timeForDistance
&&
currentTime
<=
measure
.
ms
+
350
){
this
.
drawMeasure
(
measure
)
}
})
}
drawMeasure
(
measure
){
var
z
=
this
.
canvas
.
scale
var
currentTime
=
this
.
controller
.
getElapsedTime
()
var
measureX
=
this
.
slotX
+
this
.
msToPos
(
measure
.
ms
-
currentTime
,
measure
.
speed
)
this
.
ctx
.
strokeStyle
=
"
#bab8b8
"
this
.
ctx
.
lineWidth
=
2
this
.
ctx
.
beginPath
()
this
.
ctx
.
moveTo
(
measureX
,
this
.
barY
+
5
*
z
)
this
.
ctx
.
lineTo
(
measureX
,
this
.
barY
+
this
.
barH
-
this
.
lyricsBarH
-
5
*
z
)
this
.
ctx
.
closePath
()
this
.
ctx
.
stroke
()
}
drawCombo
(){
var
comboCount
=
this
.
controller
.
getCombo
()
var
comboCount
=
this
.
controller
.
getCombo
()
if
(
comboCount
>=
10
){
if
(
comboCount
>=
10
){
var
comboX
=
this
.
taikoX
+
this
.
taikoW
/
2
var
comboY
=
this
.
barY
+
this
.
barH
/
2
var
fontSize
=
this
.
taikoH
*
0.4
this
.
ctx
.
font
=
"
normal
"
+
fontSize
+
"
px TnT, Meiryo, sans-serif
"
this
.
ctx
.
textAlign
=
"
center
"
this
.
ctx
.
strokeStyle
=
"
#000
"
this
.
ctx
.
lineWidth
=
fontSize
/
10
var
glyph
=
this
.
ctx
.
measureText
(
"
0
"
).
width
var
comboText
=
comboCount
.
toString
().
split
(
""
)
var
comboText
=
comboCount
.
toString
().
split
(
""
)
var
mul
=
this
.
portrait
?
0.8
:
1
var
comboX
=
taikoPos
.
x
+
taikoPos
.
w
/
2
var
comboY
=
taikoPos
.
y
+
taikoPos
.
h
*
0.09
var
comboScale
=
0
if
(
this
.
currentScore
!==
0
&&
scoreMS
<
100
){
comboScale
=
this
.
draw
.
fade
(
scoreMS
/
100
)
}
var
glyphW
=
51
var
glyphH
=
64
var
letterSpacing
=
(
comboText
.
length
>=
4
?
38
:
42
)
*
mul
var
orange
=
comboCount
>=
100
?
"
1
"
:
"
0
"
var
w
=
glyphW
*
mul
var
h
=
glyphH
*
mul
*
(
1
+
comboScale
/
8
)
for
(
var
i
in
comboText
){
for
(
var
i
in
comboText
){
var
textX
=
comboX
+
glyph
*
(
i
-
(
comboText
.
length
-
1
)
/
2
)
var
textX
=
comboX
+
letterSpacing
*
(
i
-
(
comboText
.
length
-
1
)
/
2
)
if
(
comboCount
>=
100
){
this
.
comboCache
.
get
({
var
grd
=
this
.
ctx
.
createLinearGradient
(
ctx
:
ctx
,
textX
-
glyph
*
0.2
,
x
:
textX
-
w
/
2
,
comboY
-
fontSize
*
0.8
,
y
:
comboY
+
glyphH
*
mul
-
h
,
textX
+
glyph
*
0.2
,
w
:
w
,
comboY
-
fontSize
*
0.2
h
:
h
,
id
:
orange
+
"
combo
"
+
comboText
[
i
]
})
}
var
fontSize
=
24
*
mul
var
comboTextY
=
taikoPos
.
y
+
taikoPos
.
h
*
0.63
if
(
orange
===
"
1
"
){
var
grd
=
ctx
.
createLinearGradient
(
0
,
comboTextY
-
fontSize
*
0.6
,
0
,
comboTextY
+
fontSize
*
0.1
)
)
grd
.
addColorStop
(
0
,
"
#f00
"
)
grd
.
addColorStop
(
0
,
"
#ff2000
"
)
grd
.
addColorStop
(
1
,
"
#fe0
"
)
grd
.
addColorStop
(
0.5
,
"
#ffc321
"
)
this
.
ctx
.
fillStyle
=
grd
grd
.
addColorStop
(
1
,
"
#ffedb7
"
)
ctx
.
fillStyle
=
grd
}
else
{
}
else
{
this
.
ctx
.
fillStyle
=
"
#fff
"
ctx
.
fillStyle
=
"
#fff
"
}
}
this
.
strokeFillText
(
comboText
[
i
],
ctx
.
font
=
fontSize
+
"
px
"
+
this
.
font
textX
,
ctx
.
lineWidth
=
7
*
mul
comboY
ctx
.
textAlign
=
"
center
"
)
ctx
.
strokeText
(
"
コンボ
"
,
comboX
,
comboTextY
)
ctx
.
fillText
(
"
コンボ
"
,
comboX
,
comboTextY
)
}
}
var
fontSize
=
this
.
taikoH
*
0.12
// Slot
if
(
comboCount
>=
100
){
this
.
draw
.
slot
(
ctx
,
this
.
slotPos
.
x
,
this
.
slotPos
.
y
,
this
.
slotPos
.
size
)
var
grd
=
this
.
ctx
.
createLinearGradient
(
0
,
comboY
+
fontSize
*
0.5
,
0
,
comboY
+
fontSize
*
1.5
)
grd
.
addColorStop
(
0
,
"
#f00
"
)
// Measures
grd
.
addColorStop
(
1
,
"
#fe0
"
)
ctx
.
save
()
this
.
ctx
.
fillStyle
=
grd
ctx
.
rect
(
this
.
slotPos
.
paddingLeft
,
0
,
winW
-
this
.
slotPos
.
paddingLeft
,
winH
)
}
else
{
ctx
.
clip
()
this
.
ctx
.
fillStyle
=
"
#fff
"
this
.
drawMeasures
()
}
ctx
.
restore
()
this
.
ctx
.
font
=
"
normal
"
+
fontSize
+
"
px TnT, Meiryo, sans-serif
"
this
.
ctx
.
lineWidth
=
fontSize
/
5
// Go go time fire
this
.
strokeFillText
(
"
コンボ
"
,
this
.
assets
.
drawAssets
(
"
bar
"
)
comboX
,
comboY
+
fontSize
*
1.5
// Hit notes shadow
if
(
scoreMS
<
300
&&
this
.
currentScore
.
type
){
var
fadeOut
=
scoreMS
>
120
&&
!
this
.
touchEnabled
if
(
fadeOut
){
ctx
.
globalAlpha
=
1
-
(
scoreMS
-
120
)
/
180
}
var
scoreId
=
this
.
currentScore
.
type
===
230
?
0
:
1
if
(
this
.
currentScore
.
bigNote
){
scoreId
+=
2
}
ctx
.
drawImage
(
assets
.
image
[
"
notes_hit
"
],
0
,
128
*
scoreId
,
128
,
128
,
this
.
slotPos
.
x
-
64
,
this
.
slotPos
.
y
-
64
,
128
,
128
)
)
if
(
fadeOut
){
ctx
.
globalAlpha
=
1
}
}
// Future notes
this
.
updateNoteFaces
()
ctx
.
save
()
ctx
.
rect
(
this
.
slotPos
.
paddingLeft
,
0
,
winW
-
this
.
slotPos
.
paddingLeft
,
winH
)
ctx
.
clip
()
this
.
drawCircles
(
this
.
controller
.
getCircles
())
ctx
.
restore
()
// Hit notes explosion
this
.
scoreDispCount
++
// Good, OK, Bad
if
(
scoreMS
<
300
){
var
mul
=
this
.
slotPos
.
size
/
106
var
scores
=
{
"
0
"
:
"
bad
"
,
"
230
"
:
"
ok
"
,
"
450
"
:
"
good
"
}
var
yOffset
=
scoreMS
<
70
?
scoreMS
*
(
13
/
70
)
:
0
var
fadeOut
=
scoreMS
>
250
&&
!
this
.
touchEnabled
if
(
fadeOut
){
ctx
.
globalAlpha
=
1
-
(
scoreMS
-
250
)
/
50
}
this
.
draw
.
score
({
ctx
:
ctx
,
score
:
scores
[
this
.
currentScore
.
type
],
x
:
this
.
slotPos
.
x
,
y
:
this
.
slotPos
.
y
-
98
*
mul
-
yOffset
,
scale
:
1.35
*
mul
,
align
:
"
center
"
})
if
(
fadeOut
){
ctx
.
globalAlpha
=
1
}
}
}
}
strokeFillText
(
text
,
x
,
y
){
this
.
ctx
.
strokeText
(
text
,
x
,
y
)
// Animating notes
this
.
ctx
.
fillText
(
text
,
x
,
y
)
this
.
drawAnimatedCircles
(
this
.
controller
.
getCircles
())
this
.
drawAnimatedCircles
(
this
.
drumroll
)
// Go-go time fireworks
if
(
!
this
.
touchEnabled
&&
!
this
.
portrait
&&
!
this
.
multiplayer
){
this
.
assets
.
drawAssets
(
"
foreground
"
)
}
}
drawGlobalScore
(){
// Draw score square
this
.
ctx
.
fillStyle
=
"
#000
"
this
.
ctx
.
beginPath
()
this
.
ctx
.
fillRect
(
0
,
this
.
barY
,
this
.
scoreSquareW
,
this
.
scoreSquareH
-
10
)
this
.
ctx
.
fillRect
(
0
,
this
.
barY
,
this
.
scoreSquareW
-
10
,
this
.
scoreSquareH
)
this
.
ctx
.
arc
(
this
.
scoreSquareW
-
10
,
this
.
barY
+
this
.
scoreSquareH
-
10
,
10
,
0
,
Math
.
PI
*
2
)
this
.
ctx
.
fill
()
this
.
ctx
.
closePath
()
var
fontSize
=
0.7
*
this
.
scoreSquareH
// Draw score text
this
.
ctx
.
font
=
"
normal
"
+
fontSize
+
"
px TnT, Meiryo, sans-serif
"
this
.
ctx
.
fillStyle
=
"
#fff
"
this
.
ctx
.
textAlign
=
"
center
"
var
glyph
=
this
.
ctx
.
measureText
(
"
0
"
).
width
var
pointsText
=
this
.
controller
.
getGlobalScore
().
points
.
toString
().
split
(
""
)
for
(
var
i
in
pointsText
){
this
.
ctx
.
fillText
(
pointsText
[
i
],
this
.
scoreSquareW
-
30
+
glyph
*
(
i
-
pointsText
.
length
+
1
),
this
.
barY
+
this
.
scoreSquareH
*
0.7
)
}
}
setBackground
(){
var
gameDiv
=
document
.
getElementById
(
"
game
"
)
var
selectedSong
=
this
.
controller
.
selectedSong
var
bg
=
"
/songs/
"
+
selectedSong
.
folder
+
"
/bg.png
"
if
(
selectedSong
.
defaultBg
){
var
categories
=
{
"
J-POP
"
:
0
,
"
アニメ
"
:
1
,
"
ボーカロイド™曲
"
:
2
,
"
バラエティ
"
:
3
,
"
クラシック
"
:
4
,
"
ゲームミュージック
"
:
5
,
"
ナムコオリジナル
"
:
6
}
}
drawPressedKeys
(){
var
catId
=
7
var
ms
=
this
.
controller
.
getElapsedTime
()
if
(
selectedSong
.
category
in
categories
){
var
keyTime
=
this
.
controller
.
getKeyTime
()
catId
=
categories
[
selectedSong
.
category
]
var
kbd
=
this
.
controller
.
getBindings
()
if
(
keyTime
[
kbd
[
"
ka_l
"
]]
>
ms
-
150
){
var
elemW
=
0.45
*
this
.
taikoW
this
.
ctx
.
globalAlpha
=
Math
.
min
(
1
,
4
-
(
ms
-
keyTime
[
kbd
[
"
ka_l
"
]])
/
37.5
)
this
.
ctx
.
drawImage
(
assets
.
image
[
"
taiko-key-blue
"
],
0
,
0
,
68
,
124
,
this
.
taikoX
+
this
.
taikoW
*
0.05
,
this
.
taikoY
+
this
.
taikoH
*
0.03
,
elemW
,
124
/
68
*
elemW
)
}
}
if
(
keyTime
[
kbd
[
"
don_l
"
]]
>
ms
-
150
){
bg
=
assets
.
image
[
"
bg_genre_
"
+
catId
].
src
var
elemW
=
0.35
*
this
.
taikoW
gameDiv
.
classList
.
add
(
"
default-bg
"
)
this
.
ctx
.
globalAlpha
=
Math
.
min
(
1
,
4
-
(
ms
-
keyTime
[
kbd
[
"
don_l
"
]])
/
37.5
)
this
.
ctx
.
drawImage
(
assets
.
image
[
"
taiko-key-red
"
],
0
,
0
,
53
,
100
,
this
.
taikoX
+
this
.
taikoW
*
0.15
,
this
.
taikoY
+
this
.
taikoH
*
0.09
,
elemW
,
100
/
53
*
elemW
)
}
}
if
(
keyTime
[
kbd
[
"
don_r
"
]]
>
ms
-
150
){
gameDiv
.
style
.
backgroundImage
=
"
url('
"
+
bg
+
"
')
"
var
elemW
=
0.35
*
this
.
taikoW
this
.
ctx
.
globalAlpha
=
Math
.
min
(
1
,
4
-
(
ms
-
keyTime
[
kbd
[
"
don_r
"
]])
/
37.5
)
this
.
ctx
.
drawImage
(
assets
.
image
[
"
taiko-key-red
"
],
53
,
0
,
53
,
100
,
this
.
taikoX
+
this
.
taikoW
*
0.15
+
elemW
,
this
.
taikoY
+
this
.
taikoH
*
0.09
,
elemW
,
100
/
53
*
elemW
)
}
}
if
(
keyTime
[
kbd
[
"
ka_r
"
]]
>
ms
-
150
){
var
elemW
=
0.45
*
this
.
taikoW
drawMeasures
(){
this
.
ctx
.
globalAlpha
=
Math
.
min
(
1
,
4
-
(
ms
-
keyTime
[
kbd
[
"
ka_r
"
]])
/
37.5
)
var
measures
=
this
.
controller
.
parsedSongData
.
measures
this
.
ctx
.
drawImage
(
assets
.
image
[
"
taiko-key-blue
"
],
var
ms
=
this
.
getMS
()
68
,
0
,
68
,
124
,
var
mul
=
this
.
slotPos
.
size
/
106
this
.
taikoX
+
this
.
taikoW
*
0.05
+
elemW
,
var
distanceForCircle
=
this
.
winW
/
this
.
ratio
-
this
.
slotPos
.
x
this
.
taikoY
+
this
.
taikoH
*
0.03
,
var
measureY
=
this
.
slotPos
.
y
-
65
*
mul
elemW
,
var
measureH
=
130
*
mul
124
/
68
*
elemW
)
measures
.
forEach
(
measure
=>
{
var
timeForDistance
=
this
.
posToMs
(
distanceForCircle
,
measure
.
speed
)
if
(
ms
>=
measure
.
ms
-
timeForDistance
&&
ms
<=
measure
.
ms
+
350
){
var
measureX
=
this
.
slotPos
.
x
+
this
.
msToPos
(
measure
.
ms
-
ms
,
measure
.
speed
)
this
.
ctx
.
strokeStyle
=
"
#bdbdbd
"
this
.
ctx
.
lineWidth
=
3
this
.
ctx
.
beginPath
()
this
.
ctx
.
moveTo
(
measureX
,
measureY
)
this
.
ctx
.
lineTo
(
measureX
,
measureY
+
measureH
)
this
.
ctx
.
stroke
()
}
}
this
.
ctx
.
globalAlpha
=
1
})
}
}
displayScore
(
score
,
notPlayed
){
updateNoteFaces
(){
this
.
currentScore
=
score
var
ms
=
this
.
getMS
()
this
.
special
=
notPlayed
?
"
-b
"
:
""
while
(
ms
>=
this
.
nextBeat
){
this
.
scoreDispCount
=
0
this
.
nextBeat
+=
this
.
beatInterval
this
.
scoreOpacity
=
1
if
(
this
.
controller
.
getCombo
()
>=
50
){
}
var
face
=
Math
.
floor
(
ms
/
this
.
beatInterval
)
%
2
drawScore
(){
this
.
noteFace
=
{
if
(
this
.
scoreDispCount
>=
0
&&
this
.
scoreDispCount
<=
20
){
small
:
face
,
this
.
ctx
.
globalAlpha
=
this
.
scoreOpacity
big
:
face
+
2
var
scoreIMG
=
assets
.
image
[
"
score-
"
+
this
.
currentScore
+
this
.
special
]
this
.
ctx
.
drawImage
(
scoreIMG
,
this
.
slotX
-
this
.
barH
/
2
,
this
.
barY
+
(
this
.
barH
-
this
.
lyricsBarH
)
/
2
-
this
.
barH
/
2
,
this
.
barH
,
this
.
barH
)
this
.
scoreDispCount
++
if
(
this
.
scoreOpacity
-
0.1
>=
0
&&
this
.
currentScore
!=
0
){
this
.
scoreOpacity
-=
0.1
}
}
}
else
if
(
this
.
scoreDispCount
===
21
){
}
else
{
this
.
scoreDispCount
=
-
1
this
.
noteFace
=
{
small
:
0
,
big
:
3
}
}
this
.
ctx
.
globalAlpha
=
1
}
}
posToMs
(
pos
,
speed
){
return
140
/
this
.
circleSize
*
pos
/
speed
}
}
msToPos
(
ms
,
speed
){
return
speed
/
(
140
/
this
.
circleSize
)
*
ms
}
}
drawCircles
(
circles
){
drawCircles
(
circles
){
var
distanceForCircle
=
this
.
winW
/
this
.
ratio
-
this
.
slotPos
.
x
var
ms
=
this
.
controller
.
getElapsedTime
()
for
(
var
i
=
circles
.
length
;
i
--
;){
for
(
var
i
=
circles
.
length
;
i
--
;){
var
circle
=
circles
[
i
]
var
circle
=
circles
[
i
]
var
ms
=
this
.
controller
.
getElapsedTime
()
var
speed
=
circle
.
getSpeed
()
var
speed
=
circle
.
getSpeed
()
var
timeForDistance
=
this
.
posToMs
(
this
.
distanceForCircle
+
this
.
bigCircleS
ize
/
2
,
speed
)
var
timeForDistance
=
this
.
posToMs
(
distanceForCircle
+
this
.
slotPos
.
s
ize
/
2
,
speed
)
var
startingTime
=
circle
.
getMS
()
-
timeForDistance
var
startingTime
=
circle
.
getMS
()
-
timeForDistance
var
finishTime
=
circle
.
getEndTime
()
+
this
.
posToMs
(
this
.
slot
X
-
this
.
taikoSquareW
+
this
.
bigCircleSize
*
3
,
speed
)
var
finishTime
=
circle
.
getEndTime
()
+
this
.
posToMs
(
this
.
slot
Pos
.
x
-
this
.
slotPos
.
paddingLeft
+
this
.
slotPos
.
size
*
2
,
speed
)
if
(
circle
.
getPlayed
()
<=
0
||
circle
.
getScore
()
===
0
){
if
(
circle
.
getPlayed
()
<=
0
||
circle
.
getScore
()
===
0
){
if
(
ms
>=
startingTime
&&
ms
<=
finishTime
&&
circle
.
getPlayed
()
!==
-
1
){
if
(
ms
>=
startingTime
&&
ms
<=
finishTime
&&
circle
.
getPlayed
()
!==
-
1
){
this
.
drawCircle
(
circle
)
this
.
drawCircle
(
circle
)
}
}
}
else
if
(
!
circle
.
isAnimated
()){
}
else
if
(
!
circle
.
isAnimated
()){
// Start animation to
HP bar
// Start animation to
gauge
circle
.
animate
(
ms
)
circle
.
animate
(
ms
)
}
}
if
(
ms
>=
circle
.
ms
&&
!
circle
.
gogoChecked
){
if
(
ms
>=
circle
.
ms
&&
!
circle
.
gogoChecked
){
...
@@ -507,28 +832,27 @@ class View{
...
@@ -507,28 +832,27 @@ class View{
}
}
circle
.
gogoChecked
=
true
circle
.
gogoChecked
=
true
}
}
}
}
drawAnimatedCircles
(
circles
){
var
ms
=
this
.
controller
.
getElapsedTime
()
for
(
var
i
=
0
;
i
<
circles
.
length
;
i
++
){
var
circle
=
circles
[
i
]
if
(
circle
.
isAnimated
()){
if
(
circle
.
isAnimated
()){
var
animT
=
circle
.
getAnimT
()
var
animT
=
circle
.
getAnimT
()
var
animationDuration
=
400
if
(
ms
<
animT
+
490
){
if
(
ms
<=
animT
+
animationDuration
){
var
curveDistance
=
this
.
HPBarX
+
this
.
HPBarW
-
this
.
slotX
-
this
.
HPBarColH
/
2
var
animPoint
=
(
ms
-
animT
)
/
490
var
animPoint
=
(
ms
-
animT
)
/
animationDuration
var
bezierPoint
=
this
.
calcBezierPoint
(
this
.
draw
.
easeOut
(
animPoint
),
this
.
animateBezier
)
var
bezierPoint
=
this
.
calcBezierPoint
(
this
.
easeOut
(
animPoint
),
[{
x
:
this
.
slotX
+
this
.
circleSize
*
0.4
,
y
:
this
.
circleY
-
this
.
circleSize
*
0.8
},
{
x
:
this
.
slotX
+
curveDistance
*
0.15
,
y
:
this
.
barH
*
0.5
},
{
x
:
this
.
slotX
+
curveDistance
*
0.35
,
y
:
0
},
{
x
:
this
.
slotX
+
curveDistance
,
y
:
this
.
HPbarColY
+
this
.
HPBarColH
/
2
}])
this
.
drawCircle
(
circle
,
{
x
:
bezierPoint
.
x
,
y
:
bezierPoint
.
y
})
this
.
drawCircle
(
circle
,
{
x
:
bezierPoint
.
x
,
y
:
bezierPoint
.
y
})
}
else
{
}
else
if
(
ms
<
animT
+
810
){
var
pos
=
this
.
animateBezier
[
3
]
this
.
drawCircle
(
circle
,
pos
,
(
ms
-
animT
-
490
)
/
160
)
}
else
{
circle
.
endAnimation
()
circle
.
endAnimation
()
}
}
}
}
...
@@ -536,6 +860,7 @@ class View{
...
@@ -536,6 +860,7 @@ class View{
}
}
calcBezierPoint
(
t
,
data
){
calcBezierPoint
(
t
,
data
){
var
at
=
1
-
t
var
at
=
1
-
t
data
=
data
.
slice
()
for
(
var
i
=
1
;
i
<
data
.
length
;
i
++
){
for
(
var
i
=
1
;
i
<
data
.
length
;
i
++
){
for
(
var
k
=
0
;
k
<
data
.
length
-
i
;
k
++
){
for
(
var
k
=
0
;
k
<
data
.
length
-
i
;
k
++
){
...
@@ -547,11 +872,14 @@ class View{
...
@@ -547,11 +872,14 @@ class View{
}
}
return
data
[
0
]
return
data
[
0
]
}
}
easeOut
(
pos
){
drawCircle
(
circle
,
circlePos
,
fade
){
return
Math
.
sin
(
Math
.
PI
/
2
*
pos
)
var
ctx
=
this
.
ctx
}
var
mul
=
this
.
slotPos
.
size
/
106
drawCircle
(
circle
,
circlePos
){
var
z
=
this
.
canvas
.
scale
var
bigCircleSize
=
106
*
mul
/
2
var
circleSize
=
70
*
mul
/
2
var
lyricsSize
=
20
*
mul
var
fill
,
size
,
faceID
var
fill
,
size
,
faceID
var
type
=
circle
.
getType
()
var
type
=
circle
.
getType
()
var
ms
=
this
.
controller
.
getElapsedTime
()
var
ms
=
this
.
controller
.
getElapsedTime
()
...
@@ -560,54 +888,57 @@ class View{
...
@@ -560,54 +888,57 @@ class View{
var
animated
=
circle
.
isAnimated
()
var
animated
=
circle
.
isAnimated
()
var
speed
=
circle
.
getSpeed
()
var
speed
=
circle
.
getSpeed
()
var
played
=
circle
.
getPlayed
()
var
played
=
circle
.
getPlayed
()
var
drumroll
=
0
var
endX
=
0
if
(
!
circlePos
){
if
(
!
circlePos
){
circlePos
=
{
circlePos
=
{
x
:
this
.
slot
X
+
this
.
msToPos
(
circleMs
-
ms
,
speed
),
x
:
this
.
slot
Pos
.
x
+
this
.
msToPos
(
circleMs
-
ms
,
speed
),
y
:
this
.
circleY
y
:
this
.
slotPos
.
y
}
}
}
}
if
(
animated
){
if
(
animated
){
var
currentDonFace
=
0
var
noteFace
=
{
var
currentBigDonFace
=
1
small
:
0
,
big
:
3
}
}
else
{
}
else
{
var
currentDonFace
=
this
.
currentDonFace
var
noteFace
=
this
.
noteFace
var
currentBigDonFace
=
this
.
currentBigDonFace
}
}
if
(
type
===
"
don
"
||
type
===
"
daiDon
"
&&
played
===
1
){
if
(
type
===
"
don
"
||
type
===
"
daiDon
"
&&
played
===
1
){
fill
=
"
#f34728
"
fill
=
"
#f34728
"
size
=
this
.
circleSize
size
=
circleSize
faceID
=
"
don-
"
+
currentDonFace
faceID
=
noteFace
.
small
}
else
if
(
type
===
"
ka
"
||
type
===
"
daiKa
"
&&
played
===
1
){
}
else
if
(
type
===
"
ka
"
||
type
===
"
daiKa
"
&&
played
===
1
){
fill
=
"
#65bdbb
"
fill
=
"
#65bdbb
"
size
=
this
.
circleSize
size
=
circleSize
faceID
=
"
don-
"
+
currentDonFace
faceID
=
noteFace
.
small
}
else
if
(
type
===
"
daiDon
"
){
}
else
if
(
type
===
"
daiDon
"
){
fill
=
"
#f34728
"
fill
=
"
#f34728
"
size
=
this
.
bigCircleSize
size
=
bigCircleSize
faceID
=
"
big-don-
"
+
currentBigDonFace
faceID
=
noteFace
.
big
}
else
if
(
type
===
"
daiKa
"
){
}
else
if
(
type
===
"
daiKa
"
){
fill
=
"
#65bdbb
"
fill
=
"
#65bdbb
"
size
=
this
.
bigCircleSize
size
=
bigCircleSize
faceID
=
"
big-don-
"
+
currentBigDonFace
faceID
=
noteFace
.
big
}
else
if
(
type
===
"
balloon
"
){
}
else
if
(
type
===
"
balloon
"
){
if
(
animated
){
if
(
animated
){
fill
=
"
#f34728
"
fill
=
"
#f34728
"
size
=
this
.
bigCircleSize
*
0.8
size
=
bigCircleSize
*
0.8
faceID
=
"
big-don-
"
+
currentBigDonFace
faceID
=
noteFace
.
big
}
else
{
}
else
{
fill
=
"
#f87700
"
fill
=
"
#f87700
"
size
=
this
.
circleSize
size
=
circleSize
faceID
=
"
don-
"
+
currentDonFace
faceID
=
noteFace
.
small
var
h
=
size
*
1.8
var
h
=
size
*
1.8
if
(
circleMs
<
ms
&&
ms
<=
endTime
){
if
(
circleMs
<
ms
&&
ms
<=
endTime
){
circlePos
.
x
=
this
.
slot
X
circlePos
.
x
=
this
.
slot
Pos
.
x
}
else
if
(
ms
>
endTime
){
}
else
if
(
ms
>
endTime
){
circlePos
.
x
=
this
.
slot
X
+
this
.
msToPos
(
endTime
-
ms
,
speed
)
circlePos
.
x
=
this
.
slot
Pos
.
x
+
this
.
msToPos
(
endTime
-
ms
,
speed
)
}
}
this
.
ctx
.
drawImage
(
assets
.
image
[
"
balloon
"
],
ctx
.
drawImage
(
assets
.
image
[
"
balloon
"
],
circlePos
.
x
+
size
-
3
,
circlePos
.
x
+
size
-
4
,
circlePos
.
y
-
h
/
2
,
circlePos
.
y
-
h
/
2
+
2
,
h
/
61
*
115
,
h
/
61
*
115
,
h
h
)
)
...
@@ -615,188 +946,165 @@ class View{
...
@@ -615,188 +946,165 @@ class View{
}
else
if
(
type
===
"
drumroll
"
||
type
===
"
daiDrumroll
"
){
}
else
if
(
type
===
"
drumroll
"
||
type
===
"
daiDrumroll
"
){
fill
=
"
#f3b500
"
fill
=
"
#f3b500
"
if
(
type
==
"
drumroll
"
){
if
(
type
==
"
drumroll
"
){
size
=
this
.
circleSize
size
=
circleSize
faceID
=
"
don-
"
+
currentDonFace
faceID
=
noteFace
.
small
}
else
{
}
else
{
size
=
this
.
bigCircleSize
size
=
bigCircleSize
faceID
=
"
big-don-
"
+
currentBigDonFace
faceID
=
noteFace
.
big
}
var
endX
=
this
.
msToPos
(
endTime
-
circleMs
,
speed
)
this
.
ctx
.
fillStyle
=
fill
this
.
ctx
.
strokeStyle
=
"
#1f1a17
"
this
.
ctx
.
lineWidth
=
this
.
lyricsSize
/
10
this
.
ctx
.
beginPath
()
this
.
ctx
.
moveTo
(
circlePos
.
x
,
circlePos
.
y
-
size
)
this
.
ctx
.
lineTo
(
circlePos
.
x
+
endX
,
circlePos
.
y
-
size
)
this
.
ctx
.
arc
(
circlePos
.
x
+
endX
,
circlePos
.
y
,
size
,
-
Math
.
PI
/
2
,
Math
.
PI
/
2
)
this
.
ctx
.
lineTo
(
circlePos
.
x
,
circlePos
.
y
+
size
)
this
.
ctx
.
fill
()
this
.
ctx
.
stroke
()
}
}
endX
=
this
.
msToPos
(
endTime
-
circleMs
,
speed
)
drumroll
=
endX
>
50
?
2
:
1
ctx
.
fillStyle
=
fill
ctx
.
strokeStyle
=
"
#000
"
ctx
.
lineWidth
=
3
ctx
.
beginPath
()
ctx
.
moveTo
(
circlePos
.
x
,
circlePos
.
y
-
size
+
1.5
)
ctx
.
arc
(
circlePos
.
x
+
endX
,
circlePos
.
y
,
size
-
1.5
,
Math
.
PI
/
-
2
,
Math
.
PI
/
2
)
ctx
.
lineTo
(
circlePos
.
x
,
circlePos
.
y
+
size
-
1.5
)
ctx
.
fill
()
ctx
.
stroke
()
}
if
(
!
fade
||
fade
<
1
){
// Main circle
// Main circle
this
.
ctx
.
fillStyle
=
fill
ctx
.
fillStyle
=
fill
this
.
ctx
.
beginPath
()
ctx
.
beginPath
()
this
.
ctx
.
arc
(
circlePos
.
x
,
circlePos
.
y
,
size
,
0
,
Math
.
PI
*
2
)
ctx
.
arc
(
circlePos
.
x
,
circlePos
.
y
,
size
-
1
,
0
,
Math
.
PI
*
2
)
this
.
ctx
.
closePath
()
ctx
.
fill
()
this
.
ctx
.
fill
()
// Face on circle
// Face on circle
this
.
ctx
.
drawImage
(
assets
.
image
[
faceID
],
var
drawSize
=
size
circlePos
.
x
-
size
-
2
,
if
(
faceID
<
2
){
circlePos
.
y
-
size
-
4
,
drawSize
*=
bigCircleSize
/
circleSize
size
*
2
+
5
,
}
size
*
2
+
6
ctx
.
drawImage
(
assets
.
image
[
drumroll
?
"
notes_drumroll
"
:
"
notes
"
],
)
0
,
172
*
faceID
,
if
(
!
circle
.
isAnimated
()){
172
,
172
,
// Text
circlePos
.
x
-
drawSize
-
4
,
this
.
ctx
.
font
=
"
normal bold
"
+
this
.
lyricsSize
+
"
px Kozuka
"
circlePos
.
y
-
drawSize
-
4
,
this
.
ctx
.
textAlign
=
"
center
"
drawSize
*
2
+
8
,
this
.
ctx
.
strokeStyle
=
"
#000
"
drawSize
*
2
+
8
this
.
ctx
.
lineWidth
=
this
.
lyricsSize
/
5
this
.
ctx
.
fillStyle
=
"
#fff
"
this
.
strokeFillText
(
circle
.
getText
(),
circlePos
.
x
,
this
.
barY
+
this
.
barH
-
this
.
lyricsBarH
*
0.3
)
}
}
togglePauseMenu
(){
if
(
this
.
controller
.
game
.
isPaused
()){
this
.
pauseMenu
.
style
.
display
=
"
block
"
this
.
lastMousemove
=
this
.
controller
.
getElapsedTime
()
this
.
cursorHidden
=
false
this
.
mouseIdle
()
}
else
{
this
.
pauseMenu
.
style
.
display
=
""
}
}
drawDifficulty
(){
this
.
ctx
.
drawImage
(
assets
.
image
[
"
muzu_
"
+
this
.
songDifficulty
],
this
.
diffX
,
this
.
diffY
,
this
.
diffW
,
this
.
diffH
)
if
(
this
.
controller
.
autoPlayEnabled
&&
!
this
.
controller
.
multiplayer
){
this
.
ctx
.
drawImage
(
assets
.
image
[
"
badge_auto
"
],
this
.
diffX
+
this
.
diffW
*
0.71
,
this
.
diffY
+
this
.
diffH
*
0.01
,
this
.
diffH
*
0.3
,
this
.
diffH
*
0.3
)
)
}
}
this
.
ctx
.
drawImage
(
assets
.
image
.
taiko
,
if
(
fade
&&
!
this
.
touchEnabled
){
this
.
taikoX
,
this
.
taikoY
,
ctx
.
globalAlpha
=
this
.
draw
.
easeOut
(
fade
<
1
?
fade
:
2
-
fade
)
this
.
taikoW
,
this
.
taikoH
ctx
.
fillStyle
=
"
#fff
"
)
ctx
.
beginPath
()
}
ctx
.
arc
(
circlePos
.
x
,
circlePos
.
y
,
size
-
1
,
0
,
Math
.
PI
*
2
)
drawTime
(){
ctx
.
fill
()
var
z
=
this
.
canvas
.
scale
ctx
.
globalAlpha
=
1
var
ms
=
this
.
controller
.
getElapsedTime
()
var
sign
=
Math
.
sign
(
ms
)
<
0
?
"
-
"
:
""
ms
=
Math
.
abs
(
ms
)
+
(
sign
===
"
-
"
?
1000
:
0
)
var
time
=
{
sec
:
Math
.
floor
(
ms
/
1000
)
%
60
,
min
:
Math
.
floor
(
ms
/
1000
/
60
)
%
60
,
hour
:
Math
.
floor
(
ms
/
1000
/
60
/
60
)
%
60
}
}
if
(
!
circle
.
isAnimated
()){
// Text
var
text
=
circle
.
getText
()
var
textX
=
circlePos
.
x
var
textY
=
circlePos
.
y
+
83
*
mul
ctx
.
font
=
lyricsSize
+
"
px Kozuka
"
ctx
.
textBaseline
=
"
middle
"
ctx
.
textAlign
=
"
center
"
this
.
ctx
.
globalAlpha
=
0.7
if
(
drumroll
===
2
){
this
.
ctx
.
fillStyle
=
"
#000
"
var
longText
=
text
.
split
(
"
ー
"
)
this
.
ctx
.
fillRect
(
this
.
winW
-
110
*
z
,
this
.
winH
-
60
*
z
,
this
.
winW
,
this
.
winH
)
text
=
longText
[
0
]
var
text0Width
=
ctx
.
measureText
(
longText
[
0
]).
width
var
text1Width
=
ctx
.
measureText
(
longText
[
1
]).
width
}
this
.
ctx
.
globalAlpha
=
1
ctx
.
fillStyle
=
"
#fff
"
this
.
ctx
.
fillStyle
=
"
#fff
"
ctx
.
strokeStyle
=
"
#000
"
ctx
.
lineWidth
=
5
ctx
.
strokeText
(
text
,
textX
,
textY
)
var
formatedH
=
(
"
0
"
+
time
.
hour
).
slice
(
-
2
)
if
(
drumroll
===
2
){
var
formatedM
=
(
"
0
"
+
time
.
min
).
slice
(
-
2
)
ctx
.
strokeText
(
longText
[
1
],
textX
+
endX
,
textY
)
var
formatedS
=
(
"
0
"
+
time
.
sec
).
slice
(
-
2
)
this
.
ctx
.
font
=
"
normal
"
+
(
this
.
barH
/
12
)
+
"
px Kozuka
"
ctx
.
lineWidth
=
4
this
.
ctx
.
textAlign
=
"
right
"
var
x1
=
textX
+
text0Width
/
2
this
.
ctx
.
fillText
(
sign
+
formatedH
+
"
:
"
+
formatedM
+
"
:
"
+
formatedS
,
var
x2
=
textX
+
endX
-
text1Width
/
2
this
.
winW
-
10
*
z
,
this
.
winH
-
30
*
z
ctx
.
beginPath
()
)
ctx
.
moveTo
(
x1
,
textY
-
2
)
this
.
ctx
.
fillText
(
sign
+
Math
.
floor
(
ms
),
this
.
winW
-
10
*
z
,
this
.
winH
-
10
*
z
)
ctx
.
lineTo
(
x2
,
textY
-
2
)
ctx
.
lineTo
(
x2
,
textY
+
1
)
ctx
.
lineTo
(
x1
,
textY
+
1
)
ctx
.
closePath
()
ctx
.
stroke
()
ctx
.
fill
()
}
}
drawBar
(){
this
.
ctx
.
strokeStyle
=
"
#000
"
this
.
ctx
.
fillStyle
=
"
#232323
"
this
.
ctx
.
lineWidth
=
10
this
.
ctx
.
beginPath
()
this
.
ctx
.
rect
(
0
,
this
.
barY
,
this
.
winW
,
this
.
barH
)
this
.
ctx
.
closePath
()
this
.
ctx
.
fill
()
var
ms
=
this
.
controller
.
getElapsedTime
()
ctx
.
strokeStyle
=
"
#fff
"
var
keyTime
=
this
.
controller
.
getKeyTime
()
ctx
.
lineWidth
=
0.5
var
sound
=
keyTime
[
"
don
"
]
>
keyTime
[
"
ka
"
]
?
"
don
"
:
"
ka
"
if
(
this
.
gogoTime
||
ms
<=
this
.
gogoTimeStarted
+
100
){
ctx
.
strokeText
(
text
,
textX
,
textY
)
var
grd
=
this
.
ctx
.
createLinearGradient
(
0
,
this
.
barY
,
this
.
winW
,
this
.
barH
)
ctx
.
fillText
(
text
,
textX
,
textY
)
grd
.
addColorStop
(
0
,
"
#512a2c
"
)
grd
.
addColorStop
(
0.46
,
"
#6f2a2d
"
)
if
(
drumroll
){
grd
.
addColorStop
(
0.76
,
"
#8a4763
"
)
ctx
.
strokeText
(
longText
[
1
],
textX
+
endX
,
textY
)
grd
.
addColorStop
(
1
,
"
#2c2a2c
"
)
ctx
.
fillText
(
longText
[
1
],
textX
+
endX
,
textY
)
this
.
ctx
.
fillStyle
=
grd
this
.
ctx
.
rect
(
0
,
this
.
barY
,
this
.
winW
,
this
.
barH
)
var
alpha
=
Math
.
min
(
100
,
this
.
controller
.
getElapsedTime
()
-
this
.
gogoTimeStarted
)
/
100
if
(
!
this
.
gogoTime
){
alpha
=
1
-
alpha
}
}
this
.
ctx
.
globalAlpha
=
alpha
this
.
ctx
.
fill
()
this
.
ctx
.
globalAlpha
=
1
}
}
if
(
keyTime
[
sound
]
>
ms
-
200
){
var
gradients
=
{
"
don
"
:
[
"
#f54c25
"
,
"
#232323
"
],
"
ka
"
:
[
"
#75cee9
"
,
"
#232323
"
]
}
var
grd
=
this
.
ctx
.
createLinearGradient
(
0
,
this
.
barY
,
this
.
winW
,
this
.
barH
)
grd
.
addColorStop
(
0
,
gradients
[
sound
][
0
])
grd
.
addColorStop
(
1
,
gradients
[
sound
][
1
])
this
.
ctx
.
fillStyle
=
grd
this
.
ctx
.
rect
(
0
,
this
.
barY
,
this
.
winW
,
this
.
barH
)
this
.
ctx
.
globalAlpha
=
1
-
(
ms
-
keyTime
[
sound
])
/
200
this
.
ctx
.
fill
()
this
.
ctx
.
globalAlpha
=
1
}
}
this
.
ctx
.
stroke
()
fillComboCache
(){
// Lyrics bar
var
fontSize
=
58
this
.
ctx
.
fillStyle
=
"
#888888
"
var
letterSpacing
=
fontSize
*
0.67
this
.
ctx
.
beginPath
()
var
glyphW
=
50
this
.
ctx
.
rect
(
0
,
this
.
barY
+
this
.
barH
-
this
.
lyricsBarH
,
this
.
winW
,
this
.
lyricsBarH
)
var
glyphH
=
64
this
.
ctx
.
closePath
()
var
textX
=
11
this
.
ctx
.
fill
()
var
textY
=
5
this
.
ctx
.
stroke
()
var
letterBorder
=
fontSize
*
0.15
this
.
comboCache
.
resize
((
glyphW
+
1
)
*
20
,
glyphH
+
1
,
this
.
ratio
)
for
(
var
orange
=
0
;
orange
<
2
;
orange
++
){
for
(
var
i
=
0
;
i
<
10
;
i
++
){
this
.
comboCache
.
set
({
w
:
glyphW
,
h
:
glyphH
,
id
:
orange
+
"
combo
"
+
i
},
ctx
=>
{
ctx
.
scale
(
0.9
,
1
)
if
(
orange
){
var
grd
=
ctx
.
createLinearGradient
(
(
glyphW
-
glyphH
)
/
2
,
0
,
(
glyphW
+
glyphH
)
/
2
,
glyphH
)
grd
.
addColorStop
(
0.3
,
"
#ff2000
"
)
grd
.
addColorStop
(
0.5
,
"
#ffc321
"
)
grd
.
addColorStop
(
0.6
,
"
#ffedb7
"
)
grd
.
addColorStop
(
0.8
,
"
#ffffce
"
)
var
fill
=
grd
}
else
{
var
fill
=
"
#fff
"
}
this
.
draw
.
layeredText
({
ctx
:
ctx
,
text
:
i
.
toString
(),
fontSize
:
fontSize
,
fontFamily
:
this
.
font
,
x
:
textX
,
y
:
textY
},
[
{
x
:
-
2
,
y
:
-
1
,
outline
:
"
#000
"
,
letterBorder
:
letterBorder
},
{
x
:
3.5
,
y
:
1.5
},
{
x
:
3
,
y
:
1
},
{},
{
x
:
-
2
,
y
:
-
1
,
fill
:
"
#fff
"
},
{
x
:
3.5
,
y
:
1.5
,
fill
:
fill
},
{
x
:
3
,
y
:
1
,
fill
:
"
rgba(0, 0, 0, 0.5)
"
},
{
fill
:
fill
}
])
})
}
}
drawSlot
(){
// Main circle
this
.
ctx
.
fillStyle
=
"
#6f6f6e
"
this
.
ctx
.
beginPath
()
this
.
ctx
.
arc
(
this
.
slotX
,
this
.
circleY
,
this
.
circleSize
-
0.2
*
this
.
circleSize
,
0
,
2
*
Math
.
PI
)
this
.
ctx
.
closePath
()
this
.
ctx
.
fill
()
// Big stroke circle
this
.
ctx
.
strokeStyle
=
"
#9e9f9f
"
this
.
ctx
.
lineWidth
=
3
this
.
ctx
.
beginPath
()
this
.
ctx
.
arc
(
this
.
slotX
,
this
.
circleY
,
this
.
circleSize
,
0
,
2
*
Math
.
PI
)
this
.
ctx
.
closePath
()
this
.
ctx
.
stroke
()
// Bigger stroke circle
this
.
ctx
.
strokeStyle
=
"
#6f6f6e
"
this
.
ctx
.
lineWidth
=
3
this
.
ctx
.
beginPath
()
this
.
ctx
.
arc
(
this
.
slotX
,
this
.
circleY
,
this
.
bigCircleSize
,
0
,
2
*
Math
.
PI
)
this
.
ctx
.
closePath
()
this
.
ctx
.
stroke
()
}
}
drawTaikoSquare
(){
this
.
globalAlpha
=
0
// Taiko square
this
.
comboCache
.
get
({
this
.
ctx
.
lineWidth
=
7
ctx
:
this
.
ctx
,
this
.
ctx
.
fillStyle
=
"
#ff3c00
"
x
:
0
,
this
.
ctx
.
strokeStyle
=
"
#000
"
y
:
0
,
this
.
ctx
.
beginPath
()
w
:
54
,
this
.
ctx
.
rect
(
0
,
this
.
barY
,
this
.
taikoSquareW
,
this
.
barH
)
h
:
77
,
this
.
ctx
.
fill
()
id
:
"
combo0
"
this
.
ctx
.
closePath
(
)
}
)
this
.
ctx
.
stroke
()
this
.
globalAlpha
=
1
}
}
toggleGogoTime
(
circle
){
toggleGogoTime
(
circle
){
this
.
gogoTime
=
circle
.
gogoTime
this
.
gogoTime
=
circle
.
gogoTime
...
@@ -823,7 +1131,7 @@ class View{
...
@@ -823,7 +1131,7 @@ class View{
}
}
}
}
drawGogoTime
(){
drawGogoTime
(){
var
ms
=
this
.
controller
.
getElapsedTime
()
var
ms
=
this
.
getMS
()
if
(
this
.
gogoTime
){
if
(
this
.
gogoTime
){
var
circles
=
this
.
controller
.
parsedSongData
.
circles
var
circles
=
this
.
controller
.
parsedSongData
.
circles
...
@@ -837,7 +1145,9 @@ class View{
...
@@ -837,7 +1145,9 @@ class View{
}
}
}
else
{
}
else
{
var
animation
=
this
.
assets
.
don
.
getAnimation
()
var
animation
=
this
.
assets
.
don
.
getAnimation
()
if
(
animation
===
"
gogo
"
||
this
.
controller
.
getGlobalScore
().
gauge
>=
50
&&
animation
===
"
normal
"
){
var
gauge
=
this
.
controller
.
getGlobalScore
().
gauge
var
cleared
=
Math
.
round
(
gauge
/
2
)
-
1
>=
25
if
(
animation
===
"
gogo
"
||
cleared
&&
animation
===
"
normal
"
||
!
cleared
&&
animation
===
"
clear
"
){
this
.
assets
.
don
.
normalAnimation
()
this
.
assets
.
don
.
normalAnimation
()
}
}
if
(
ms
>=
this
.
gogoTimeStarted
+
100
){
if
(
ms
>=
this
.
gogoTimeStarted
+
100
){
...
@@ -864,12 +1174,38 @@ class View{
...
@@ -864,12 +1174,38 @@ class View{
don
.
setAnimationEnd
(
length
,
don
.
normalAnimation
)
don
.
setAnimationEnd
(
length
,
don
.
normalAnimation
)
}
}
}
}
displayScore
(
score
,
notPlayed
,
bigNote
){
if
(
!
notPlayed
){
this
.
currentScore
.
ms
=
this
.
getMS
()
this
.
currentScore
.
type
=
score
this
.
currentScore
.
bigNote
=
bigNote
}
}
posToMs
(
pos
,
speed
){
var
circleSize
=
70
*
this
.
slotPos
.
size
/
106
/
2
return
140
/
circleSize
*
pos
/
speed
}
msToPos
(
ms
,
speed
){
var
circleSize
=
70
*
this
.
slotPos
.
size
/
106
/
2
return
speed
/
(
140
/
circleSize
)
*
ms
}
togglePauseMenu
(){
if
(
this
.
controller
.
game
.
isPaused
()){
this
.
pauseMenu
.
style
.
display
=
"
block
"
this
.
lastMousemove
=
this
.
controller
.
getElapsedTime
()
this
.
cursorHidden
=
false
this
.
mouseIdle
()
}
else
{
this
.
pauseMenu
.
style
.
display
=
""
}
}
drawTouch
(){
drawTouch
(){
if
(
this
.
touchEnabled
){
if
(
this
.
touchEnabled
){
var
ms
=
this
.
controller
.
getElapsedTime
()
var
ms
=
this
.
getMS
()
var
mul
=
this
.
ratio
/
this
.
pixelRatio
var
drumWidth
=
this
.
touchDrum
.
w
/
this
.
canvas
.
scale
var
drumWidth
=
this
.
touchDrum
.
w
*
mul
var
drumHeight
=
this
.
touchDrum
.
h
/
this
.
canvas
.
scale
var
drumHeight
=
this
.
touchDrum
.
h
*
mul
if
(
drumHeight
!==
this
.
touchDrumHeight
||
drumWidth
!==
this
.
touchDrumWidth
){
if
(
drumHeight
!==
this
.
touchDrumHeight
||
drumWidth
!==
this
.
touchDrumWidth
){
this
.
touchDrumWidth
=
drumWidth
this
.
touchDrumWidth
=
drumWidth
this
.
touchDrumHeight
=
drumHeight
this
.
touchDrumHeight
=
drumHeight
...
@@ -890,9 +1226,8 @@ class View{
...
@@ -890,9 +1226,8 @@ class View{
ontouch
(
event
){
ontouch
(
event
){
for
(
let
touch
of
event
.
changedTouches
){
for
(
let
touch
of
event
.
changedTouches
){
event
.
preventDefault
()
event
.
preventDefault
()
var
scale
=
this
.
canvas
.
scale
var
pageX
=
touch
.
pageX
*
this
.
pixelRatio
var
pageX
=
touch
.
pageX
*
scale
var
pageY
=
touch
.
pageY
*
this
.
pixelRatio
var
pageY
=
touch
.
pageY
*
scale
var
c
=
this
.
touchCircle
var
c
=
this
.
touchCircle
var
pi
=
Math
.
PI
var
pi
=
Math
.
PI
...
@@ -947,17 +1282,19 @@ class View{
...
@@ -947,17 +1282,19 @@ class View{
this
.
beatInterval
=
beatMS
this
.
beatInterval
=
beatMS
this
.
assets
.
changeBeatInterval
(
beatMS
)
this
.
assets
.
changeBeatInterval
(
beatMS
)
}
}
clean
(){
getMS
(){
pageEvents
.
mouseRemove
(
this
)
return
this
.
controller
.
getElapsedTime
()
if
(
this
.
controller
.
multiplayer
===
2
){
if
(
this
.
canvas
){
this
.
canvas
.
canvas
.
parentNode
.
removeChild
(
this
.
canvas
.
canvas
)
}
}
else
{
this
.
cursor
.
parentNode
.
removeChild
(
this
.
cursor
)
}
}
clean
(){
this
.
draw
.
clean
()
this
.
assets
.
clean
()
this
.
titleCache
.
clean
()
this
.
comboCache
.
clean
()
if
(
this
.
multiplayer
!==
2
){
pageEvents
.
remove
(
window
,
"
resize
"
)
if
(
this
.
touchEnabled
){
if
(
this
.
touchEnabled
){
pageEvents
.
remove
(
this
.
canva
s
.
canvas
,
"
touchstart
"
)
pageEvents
.
remove
(
thi
s
.
canvas
,
"
touchstart
"
)
pageEvents
.
remove
(
this
.
touchFullBtn
,
"
touchend
"
)
pageEvents
.
remove
(
this
.
touchFullBtn
,
"
touchend
"
)
pageEvents
.
remove
(
this
.
touchPauseBtn
,
"
touchend
"
)
pageEvents
.
remove
(
this
.
touchPauseBtn
,
"
touchend
"
)
this
.
gameDiv
.
classList
.
remove
(
"
touch-visible
"
)
this
.
gameDiv
.
classList
.
remove
(
"
touch-visible
"
)
...
@@ -967,6 +1304,8 @@ class View{
...
@@ -967,6 +1304,8 @@ class View{
delete
this
.
touchFullBtn
delete
this
.
touchFullBtn
delete
this
.
touchPauseBtn
delete
this
.
touchPauseBtn
}
}
}
pageEvents
.
mouseRemove
(
this
)
delete
this
.
pauseMenu
delete
this
.
pauseMenu
delete
this
.
cursor
delete
this
.
cursor
delete
this
.
gameDiv
delete
this
.
gameDiv
...
...
public/src/js/viewassets.js
View file @
5a115040
...
@@ -9,17 +9,17 @@ class ViewAssets{
...
@@ -9,17 +9,17 @@ class ViewAssets{
var
imgw
=
360
var
imgw
=
360
var
imgh
=
184
var
imgh
=
184
var
scale
=
165
var
scale
=
165
var
w
=
(
this
.
view
.
barH
*
imgw
)
/
scale
var
w
=
imgw
var
h
=
(
this
.
view
.
barH
*
imgh
)
/
scale
var
h
=
imgh
return
{
return
{
sx
:
Math
.
floor
(
frame
/
10
)
*
imgw
,
sx
:
Math
.
floor
(
frame
/
10
)
*
imgw
,
sy
:
(
frame
%
10
)
*
imgh
,
sy
:
(
frame
%
10
)
*
imgh
+
1
,
sw
:
imgw
,
sw
:
imgw
,
sh
:
imgh
,
sh
:
imgh
-
1
,
x
:
this
.
view
.
taikoSquareW
-
w
+
this
.
view
.
barH
*
0.2
,
x
:
view
.
portrait
?
-
60
:
0
,
y
:
this
.
view
.
barY
-
h
,
y
:
view
.
portrait
?
(
view
.
multiplayer
===
2
?
560
:
35
)
:
(
view
.
multiplayer
===
2
?
360
:
2
)
,
w
:
w
,
w
:
w
,
h
:
h
h
:
h
-
1
}
}
})
})
this
.
don
.
addFrames
(
"
normal
"
,
[
this
.
don
.
addFrames
(
"
normal
"
,
[
...
@@ -41,7 +41,7 @@ class ViewAssets{
...
@@ -41,7 +41,7 @@ class ViewAssets{
var
length
=
this
.
don
.
getAnimationLength
(
"
gogo
"
)
var
length
=
this
.
don
.
getAnimationLength
(
"
gogo
"
)
this
.
don
.
setUpdateSpeed
(
4
/
length
)
this
.
don
.
setUpdateSpeed
(
4
/
length
)
this
.
don
.
setAnimation
(
"
gogo
"
)
this
.
don
.
setAnimation
(
"
gogo
"
)
}
else
if
(
this
.
controller
.
getGlobalScore
().
gauge
>=
50
){
}
else
if
(
Math
.
round
(
this
.
controller
.
getGlobalScore
().
gauge
/
2
)
-
1
>=
25
){
this
.
don
.
setAnimationStart
(
0
)
this
.
don
.
setAnimationStart
(
0
)
var
length
=
this
.
don
.
getAnimationLength
(
"
clear
"
)
var
length
=
this
.
don
.
getAnimationLength
(
"
clear
"
)
this
.
don
.
setUpdateSpeed
(
2
/
length
)
this
.
don
.
setUpdateSpeed
(
2
/
length
)
...
@@ -58,31 +58,31 @@ class ViewAssets{
...
@@ -58,31 +58,31 @@ class ViewAssets{
this
.
fire
=
this
.
createAsset
(
"
bar
"
,
frame
=>
{
this
.
fire
=
this
.
createAsset
(
"
bar
"
,
frame
=>
{
var
imgw
=
360
var
imgw
=
360
var
imgh
=
370
var
imgh
=
370
var
scale
=
1
75
var
scale
=
1
30
var
ms
=
this
.
controller
.
getElapsedTime
()
var
ms
=
this
.
view
.
getMS
()
var
elapsed
=
ms
-
this
.
view
.
gogoTimeStarted
var
elapsed
=
ms
-
this
.
view
.
gogoTimeStarted
var
mul
=
this
.
view
.
slotPos
.
size
/
106
var
barH
=
130
*
mul
if
(
this
.
view
.
gogoTime
){
if
(
this
.
view
.
gogoTime
){
var
grow
=
3
-
Math
.
min
(
200
,
elapsed
)
/
100
var
grow
=
3
-
Math
.
min
(
200
,
elapsed
)
/
100
this
.
ctx
.
globalAlpha
=
Math
.
min
(
200
,
elapsed
)
/
200
this
.
ctx
.
globalAlpha
=
Math
.
min
(
200
,
elapsed
)
/
200
}
else
{
}
else
{
var
grow
=
1
-
Math
.
min
(
100
,
elapsed
)
/
100
var
grow
=
1
-
Math
.
min
(
100
,
elapsed
)
/
100
}
}
var
w
=
(
this
.
view
.
barH
*
imgw
)
/
scale
*
grow
var
w
=
(
barH
*
imgw
)
/
scale
*
grow
var
h
=
(
this
.
view
.
barH
*
imgh
)
/
scale
*
grow
var
h
=
(
barH
*
imgh
)
/
scale
*
grow
this
.
ctx
.
globalCompositeOperation
=
"
lighter
"
this
.
ctx
.
globalCompositeOperation
=
"
lighter
"
return
{
return
{
sx
:
frame
*
imgw
,
sx
:
frame
*
imgw
,
sy
:
0
,
sy
:
0
,
sw
:
imgw
,
sw
:
imgw
,
sh
:
imgh
,
sh
:
imgh
,
x
:
this
.
view
.
slot
X
-
w
/
2
,
x
:
this
.
view
.
slot
Pos
.
x
-
w
/
2
,
y
:
this
.
view
.
circleY
-
h
/
2
,
y
:
this
.
view
.
slotPos
.
y
-
h
/
2
,
w
:
w
,
w
:
w
,
h
:
h
,
h
:
h
callback
:
()
=>
{
this
.
ctx
.
globalCompositeOperation
=
"
source-over
"
this
.
ctx
.
globalAlpha
=
1
}
}
}
})
})
this
.
fire
.
addFrames
(
"
normal
"
,
7
,
"
fire_anim
"
)
this
.
fire
.
addFrames
(
"
normal
"
,
7
,
"
fire_anim
"
)
...
@@ -93,15 +93,17 @@ class ViewAssets{
...
@@ -93,15 +93,17 @@ class ViewAssets{
var
imgw
=
230
var
imgw
=
230
var
imgh
=
460
var
imgh
=
460
var
scale
=
165
var
scale
=
165
var
w
=
(
this
.
view
.
barH
*
imgw
)
/
scale
var
w
=
imgw
var
h
=
(
this
.
view
.
barH
*
imgh
)
/
scale
var
h
=
imgh
var
winW
=
this
.
view
.
winW
/
this
.
view
.
ratio
var
winH
=
this
.
view
.
winH
/
this
.
view
.
ratio
return
{
return
{
sx
:
Math
.
floor
(
frame
/
4
)
*
imgw
,
sx
:
Math
.
floor
(
frame
/
4
)
*
imgw
,
sy
:
(
frame
%
4
)
*
imgh
,
sy
:
(
frame
%
4
)
*
imgh
,
sw
:
imgw
,
sw
:
imgw
,
sh
:
imgh
,
sh
:
imgh
,
x
:
this
.
view
.
winW
/
4
*
i
-
w
/
2
*
(
i
/
2
),
x
:
winW
/
4
*
i
-
w
/
2
*
(
i
/
2
),
y
:
this
.
view
.
winH
-
h
,
y
:
winH
-
h
,
w
:
w
,
w
:
w
,
h
:
h
h
:
h
}
}
...
@@ -118,17 +120,22 @@ class ViewAssets{
...
@@ -118,17 +120,22 @@ class ViewAssets{
return
asset
return
asset
}
}
drawAssets
(
layer
){
drawAssets
(
layer
){
if
(
this
.
controller
.
multiplayer
!==
2
||
layer
===
"
bar
"
){
this
.
allAssets
.
forEach
(
asset
=>
{
this
.
allAssets
.
forEach
(
asset
=>
{
if
(
layer
===
asset
.
layer
){
if
(
layer
===
asset
.
layer
){
asset
.
draw
()
asset
.
draw
()
}
}
})
})
}
}
}
changeBeatInterval
(
beatMS
,
initial
){
changeBeatInterval
(
beatMS
,
initial
){
this
.
allAssets
.
forEach
(
asset
=>
{
this
.
allAssets
.
forEach
(
asset
=>
{
asset
.
changeBeatInterval
(
beatMS
,
initial
)
asset
.
changeBeatInterval
(
beatMS
,
initial
)
})
})
}
}
clean
(){
delete
this
.
ctx
delete
this
.
don
delete
this
.
fire
delete
this
.
fireworks
delete
this
.
allAssets
}
}
}
public/src/views/game.html
View file @
5a115040
<div
id=
"game"
>
<div
id=
"game"
>
<h3
alt=
""
class=
"stroke-sub game-song"
></h3>
<div
id=
"touch-drum"
>
<div
id=
"touch-drum"
>
<img
id=
"touch-drum-img"
src=
"/assets/img/touch_drum.png"
>
<img
id=
"touch-drum-img"
src=
"/assets/img/touch_drum.png"
>
</div>
</div>
...
...
templates/index.html
View file @
5a115040
...
@@ -39,8 +39,6 @@
...
@@ -39,8 +39,6 @@
<script
src=
"/src/js/mekadon.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/mekadon.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/gamepad.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/gamepad.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/tutorial.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/tutorial.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/scalablecanvas.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/element.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/soundbuffer.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/soundbuffer.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/p2.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/p2.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/canvasasset.js?{{version.commit_short}}"
></script>
<script
src=
"/src/js/canvasasset.js?{{version.commit_short}}"
></script>
...
...
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