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
9f3ee97b
Commit
9f3ee97b
authored
Nov 23, 2018
by
Bui
Committed by
GitHub
Nov 23, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #79 from LoveEevee/view-add-song-bg
View: Add song backgrounds
parents
8f1f029b
edd76b55
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
150 additions
and
30 deletions
+150
-30
public/src/css/game.css
public/src/css/game.css
+1
-4
public/src/css/songbg.css
public/src/css/songbg.css
+73
-0
public/src/js/assets.js
public/src/js/assets.js
+3
-0
public/src/js/controller.js
public/src/js/controller.js
+9
-9
public/src/js/game.js
public/src/js/game.js
+2
-0
public/src/js/loadsong.js
public/src/js/loadsong.js
+29
-5
public/src/js/view.js
public/src/js/view.js
+27
-12
public/src/views/game.html
public/src/views/game.html
+5
-0
templates/index.html
templates/index.html
+1
-0
No files found.
public/src/css/game.css
View file @
9f3ee97b
...
@@ -3,11 +3,8 @@
...
@@ -3,11 +3,8 @@
height
:
100%
;
height
:
100%
;
position
:
absolute
;
position
:
absolute
;
overflow
:
hidden
;
overflow
:
hidden
;
background-size
:
cover
;
background-position
:
center
;
}
#game
.default-bg
{
background-size
:
calc
(
100vh
/
720
*
512
);
background-size
:
calc
(
100vh
/
720
*
512
);
background-position
:
center
;
}
}
#canvas
{
#canvas
{
position
:
relative
;
position
:
relative
;
...
...
public/src/css/songbg.css
0 → 100644
View file @
9f3ee97b
#songbg
,
#songbg
>*,
#song-stage
{
position
:
absolute
;
right
:
0
;
bottom
:
0
;
left
:
0
;
width
:
100%
;
}
#songbg
{
max-width
:
calc
(
100vh
/
9
*
32
);
height
:
50.1%
;
background-color
:
#000
;
}
#songbg
>*
{
top
:
0
;
}
#songbg
,
#songbg
>*
{
background-size
:
cover
;
background-position
:
center
;
}
#song-stage
{
height
:
calc
(
44
/
720
*
100vh
);
background-position
:
center
;
}
.portrait
#songbg
{
height
:
63.4%
;
max-height
:
calc
(
50%
+
24vw
);
}
.touchp2
#songbg
{
height
:
calc
(
50%
-
5.5vw
);
}
.multiplayer.portrait
#songbg
{
height
:
calc
(
50%
-
37vw
);
min-height
:
calc
(
29%
+
1px
);
}
.multiplayer
:not
(
.touchp2
)
:not
(
.portrait
)
#songbg
,
.multiplayer
:not
(
.touchp2
)
:not
(
.portrait
)
#song-stage
{
display
:
none
;
}
.game-paused
*
{
animation-play-state
:
paused
!important
;
}
@keyframes
songbg-strobe
{
0
%
{
opacity
:
1
}
25
%
{
opacity
:
0
}
50
%
{
opacity
:
0.66
}
75
%
{
opacity
:
0
}
}
@keyframes
songbg-pulse
{
0
%
{
opacity
:
1
}
50
%
{
opacity
:
0
}
}
.songbg-1
#layer2
,
.songbg-2
#layer2
,
.songbg-3
#layer2
{
animation
:
0.4s
linear
songbg-strobe
infinite
;
mix-blend-mode
:
difference
;
}
.songbg-4
#layer2
{
animation
:
0.4s
linear
songbg-pulse
infinite
;
mix-blend-mode
:
difference
;
}
.songbg-5
#layer2
{
animation
:
1s
linear
songbg-pulse
infinite
;
mix-blend-mode
:
color-dodge
;
}
.touch-visible
#layer2
{
display
:
none
;
background-image
:
none
;
animation
:
none
;
}
public/src/js/assets.js
View file @
9f3ee97b
...
@@ -34,6 +34,9 @@ var assets = {
...
@@ -34,6 +34,9 @@ var assets = {
"
bg_score_p2.png
"
,
"
bg_score_p2.png
"
,
"
bg_settings.png
"
,
"
bg_settings.png
"
,
"
bg_pause.png
"
,
"
bg_pause.png
"
,
"
bg_stage_1.png
"
,
"
bg_stage_2.png
"
,
"
bg_stage_3.png
"
,
"
badge_auto.png
"
,
"
badge_auto.png
"
,
"
touch_drum.png
"
,
"
touch_drum.png
"
,
"
touch_pause.png
"
,
"
touch_pause.png
"
,
...
...
public/src/js/controller.js
View file @
9f3ee97b
...
@@ -7,8 +7,6 @@ class Controller{
...
@@ -7,8 +7,6 @@ class Controller{
this
.
touchEnabled
=
touchEnabled
this
.
touchEnabled
=
touchEnabled
this
.
snd
=
this
.
multiplayer
?
"
_p
"
+
this
.
multiplayer
:
""
this
.
snd
=
this
.
multiplayer
?
"
_p
"
+
this
.
multiplayer
:
""
var
backgroundURL
=
gameConfig
.
songs_baseurl
+
this
.
selectedSong
.
folder
+
"
/bg.png
"
if
(
selectedSong
.
type
===
"
tja
"
){
if
(
selectedSong
.
type
===
"
tja
"
){
this
.
parsedSongData
=
new
ParseTja
(
songData
,
selectedSong
.
difficulty
,
selectedSong
.
offset
)
this
.
parsedSongData
=
new
ParseTja
(
songData
,
selectedSong
.
difficulty
,
selectedSong
.
offset
)
}
else
{
}
else
{
...
@@ -23,7 +21,7 @@ class Controller{
...
@@ -23,7 +21,7 @@ class Controller{
})
})
this
.
game
=
new
Game
(
this
,
this
.
selectedSong
,
this
.
parsedSongData
)
this
.
game
=
new
Game
(
this
,
this
.
selectedSong
,
this
.
parsedSongData
)
this
.
view
=
new
View
(
this
,
backgroundURL
,
this
.
selectedSong
.
title
,
this
.
selectedSong
.
difficulty
)
this
.
view
=
new
View
(
this
)
this
.
mekadon
=
new
Mekadon
(
this
,
this
.
game
)
this
.
mekadon
=
new
Mekadon
(
this
,
this
.
game
)
this
.
keyboard
=
new
Keyboard
(
this
)
this
.
keyboard
=
new
Keyboard
(
this
)
...
@@ -38,13 +36,15 @@ class Controller{
...
@@ -38,13 +36,15 @@ class Controller{
syncWith
.
game
.
startDate
=
this
.
game
.
startDate
syncWith
.
game
.
startDate
=
this
.
game
.
startDate
this
.
syncWith
=
syncWith
this
.
syncWith
=
syncWith
}
}
this
.
startMainLoop
()
requestAnimationFrame
(()
=>
{
if
(
!
this
.
multiplayer
){
this
.
startMainLoop
()
debugObj
.
controller
=
this
if
(
!
this
.
multiplayer
){
if
(
debugObj
.
debug
){
debugObj
.
controller
=
this
debugObj
.
debug
.
updateStatus
()
if
(
debugObj
.
debug
){
debugObj
.
debug
.
updateStatus
()
}
}
}
}
}
)
}
}
startMainLoop
(){
startMainLoop
(){
this
.
mainLoopStarted
=
false
this
.
mainLoopStarted
=
false
...
...
public/src/js/game.js
View file @
9f3ee97b
...
@@ -349,12 +349,14 @@ class Game{
...
@@ -349,12 +349,14 @@ class Game{
this
.
mainAsset
.
stop
()
this
.
mainAsset
.
stop
()
this
.
mainMusicPlaying
=
false
this
.
mainMusicPlaying
=
false
this
.
view
.
pauseMove
(
0
,
true
)
this
.
view
.
pauseMove
(
0
,
true
)
this
.
view
.
gameDiv
.
classList
.
add
(
"
game-paused
"
)
}
else
{
}
else
{
assets
.
sounds
[
"
cancel
"
].
play
()
assets
.
sounds
[
"
cancel
"
].
play
()
this
.
paused
=
false
this
.
paused
=
false
var
currentDate
=
+
new
Date
var
currentDate
=
+
new
Date
this
.
startDate
+=
currentDate
-
this
.
latestDate
this
.
startDate
+=
currentDate
-
this
.
latestDate
this
.
sndTime
=
currentDate
-
snd
.
buffer
.
getTime
()
*
1000
this
.
sndTime
=
currentDate
-
snd
.
buffer
.
getTime
()
*
1000
this
.
view
.
gameDiv
.
classList
.
remove
(
"
game-paused
"
)
}
}
}
}
isPaused
(){
isPaused
(){
...
...
public/src/js/loadsong.js
View file @
9f3ee97b
...
@@ -12,12 +12,14 @@ class loadSong{
...
@@ -12,12 +12,14 @@ class loadSong{
var
promises
=
[]
var
promises
=
[]
assets
.
sounds
[
"
start
"
].
play
()
assets
.
sounds
[
"
start
"
].
play
()
promises
.
push
(
new
Promise
((
resolve
,
reject
)
=>
{
this
.
selectedSong
.
songBg
=
this
.
randInt
(
1
,
5
)
this
.
selectedSong
.
songStage
=
this
.
randInt
(
1
,
3
)
promises
.
push
(
new
Promise
(
resolve
=>
{
var
img
=
document
.
createElement
(
"
img
"
)
var
img
=
document
.
createElement
(
"
img
"
)
pageEvents
.
load
(
img
).
then
(
resolve
,
()
=>
{
pageEvents
.
load
(
img
).
then
(()
=>
{
this
.
selectedSong
.
defaultBg
=
true
this
.
selectedSong
.
customBg
=
true
resolve
()
},
()
=>
this
.
songBg
(
id
)).
then
(
resolve
)
})
img
.
id
=
"
music-bg
"
img
.
id
=
"
music-bg
"
img
.
src
=
gameConfig
.
songs_baseurl
+
id
+
"
/bg.png
"
img
.
src
=
gameConfig
.
songs_baseurl
+
id
+
"
/bg.png
"
document
.
getElementById
(
"
assets
"
).
appendChild
(
img
)
document
.
getElementById
(
"
assets
"
).
appendChild
(
img
)
...
@@ -50,6 +52,28 @@ class loadSong{
...
@@ -50,6 +52,28 @@ class loadSong{
alert
(
"
An error occurred, please refresh
"
)
alert
(
"
An error occurred, please refresh
"
)
})
})
}
}
songBg
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
var
filename
=
"
bg_song_
"
+
this
.
selectedSong
.
songBg
if
(
filename
+
"
a
"
in
assets
.
image
&&
filename
+
"
b
"
in
assets
.
image
){
resolve
()
}
else
{
var
promises
=
[]
for
(
var
i
=
0
;
i
<
2
;
i
++
){
let
filenameAb
=
filename
+
(
i
===
0
?
"
a
"
:
"
b
"
)
let
img
=
document
.
createElement
(
"
img
"
)
promises
.
push
(
pageEvents
.
load
(
img
).
then
(()
=>
{
assets
.
image
[
filenameAb
]
=
img
}))
img
.
src
=
gameConfig
.
assets_baseurl
+
"
img/
"
+
filenameAb
+
"
.png
"
}
return
Promise
.
all
(
promises
).
then
(
resolve
,
reject
)
}
})
}
randInt
(
min
,
max
){
return
Math
.
floor
(
Math
.
random
()
*
(
max
-
min
+
1
))
+
min
}
getSongPath
(
selectedSong
){
getSongPath
(
selectedSong
){
var
directory
=
gameConfig
.
songs_baseurl
+
selectedSong
.
folder
+
"
/
"
var
directory
=
gameConfig
.
songs_baseurl
+
selectedSong
.
folder
+
"
/
"
if
(
selectedSong
.
type
===
"
tja
"
){
if
(
selectedSong
.
type
===
"
tja
"
){
...
...
public/src/js/view.js
View file @
9f3ee97b
...
@@ -113,12 +113,16 @@
...
@@ -113,12 +113,16 @@
}
}
}
}
}
}
if
(
!
this
.
multiplayer
){
if
(
this
.
multiplayer
){
this
.
gameDiv
.
classList
.
add
(
"
multiplayer
"
)
}
else
{
pageEvents
.
add
(
this
.
canvas
,
"
mousedown
"
,
this
.
onmousedown
.
bind
(
this
))
pageEvents
.
add
(
this
.
canvas
,
"
mousedown
"
,
this
.
onmousedown
.
bind
(
this
))
}
}
}
}
run
(){
run
(){
this
.
setBackground
()
if
(
this
.
multiplayer
!==
2
){
this
.
setBackground
()
}
this
.
lastMousemove
=
this
.
controller
.
getElapsedTime
()
this
.
lastMousemove
=
this
.
controller
.
getElapsedTime
()
pageEvents
.
mouseAdd
(
this
,
this
.
onmousemove
.
bind
(
this
))
pageEvents
.
mouseAdd
(
this
,
this
.
onmousemove
.
bind
(
this
))
...
@@ -952,20 +956,31 @@
...
@@ -952,20 +956,31 @@
}
}
}
}
setBackground
(){
setBackground
(){
var
gameDiv
=
document
.
getElementById
(
"
game
"
)
var
songBg
=
document
.
getElementById
(
"
songbg
"
)
var
songStage
=
document
.
getElementById
(
"
song-stage
"
)
var
selectedSong
=
this
.
controller
.
selectedSong
var
selectedSong
=
this
.
controller
.
selectedSong
if
(
selectedSong
.
defaultBg
){
if
(
selectedSong
.
category
in
this
.
categories
){
if
(
selectedSong
.
category
in
this
.
categories
){
var
catId
=
this
.
categories
[
selectedSong
.
category
].
sort
var
catId
=
this
.
categories
[
selectedSong
.
category
].
sort
}
else
{
var
catId
=
this
.
categories
.
default
.
sort
}
var
bg
=
assets
.
image
[
"
bg_genre_
"
+
catId
].
src
gameDiv
.
classList
.
add
(
"
default-bg
"
)
}
else
{
}
else
{
var
catId
=
this
.
categories
.
default
.
sort
}
this
.
setBgImage
(
this
.
gameDiv
,
assets
.
image
[
"
bg_genre_
"
+
catId
].
src
)
if
(
selectedSong
.
customBg
){
var
bg
=
gameConfig
.
songs_baseurl
+
selectedSong
.
folder
+
"
/bg.png
"
var
bg
=
gameConfig
.
songs_baseurl
+
selectedSong
.
folder
+
"
/bg.png
"
this
.
setBgImage
(
songBg
,
bg
)
}
else
{
var
id
=
selectedSong
.
songBg
songBg
.
classList
.
add
(
"
songbg-
"
+
id
)
this
.
setBgImage
(
document
.
getElementById
(
"
layer1
"
),
assets
.
image
[
"
bg_song_
"
+
id
+
"
a
"
].
src
)
this
.
setBgImage
(
document
.
getElementById
(
"
layer2
"
),
assets
.
image
[
"
bg_song_
"
+
id
+
"
b
"
].
src
)
}
}
gameDiv
.
style
.
backgroundImage
=
"
url('
"
+
bg
+
"
')
"
songStage
.
classList
.
add
(
"
song-stage-
"
+
selectedSong
.
songStage
)
}
setBgImage
(
element
,
url
){
element
.
style
.
backgroundImage
=
"
url('
"
+
url
+
"
')
"
}
}
drawMeasures
(){
drawMeasures
(){
...
...
public/src/views/game.html
View file @
9f3ee97b
<div
id=
"game"
>
<div
id=
"game"
>
<div
id=
"songbg"
>
<div
id=
"layer1"
></div>
<div
id=
"layer2"
></div>
</div>
<div
id=
"song-stage"
></div>
<div
id=
"touch-drum"
>
<div
id=
"touch-drum"
>
<div
id=
"touch-drum-img"
></div>
<div
id=
"touch-drum-img"
></div>
</div>
</div>
...
...
templates/index.html
View file @
9f3ee97b
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
<link
rel=
"stylesheet"
href=
"/src/css/loadsong.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"/src/css/loadsong.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"/src/css/game.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"/src/css/game.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"/src/css/debug.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"/src/css/debug.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"/src/css/songbg.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"{{config.assets_baseurl}}fonts/fonts.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"{{config.assets_baseurl}}fonts/fonts.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"{{config.assets_baseurl}}img/img.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"{{config.assets_baseurl}}img/img.css?{{version.commit_short}}"
>
...
...
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