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
1d67575b
Commit
1d67575b
authored
Sep 09, 2018
by
LoveEevee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scalable game canvas
parent
a05787d8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
31 deletions
+89
-31
public/index.html
public/index.html
+1
-0
public/src/css/game.css
public/src/css/game.css
+4
-4
public/src/css/main.css
public/src/css/main.css
+14
-9
public/src/js/scalablecanvas.js
public/src/js/scalablecanvas.js
+42
-0
public/src/js/view.js
public/src/js/view.js
+28
-18
No files found.
public/index.html
View file @
1d67575b
...
...
@@ -48,6 +48,7 @@
<script
type=
'application/javascript'
src=
'/src/js/mekadon.js'
></script>
<script
type=
'application/javascript'
src=
'/src/js/gamepad.js'
></script>
<script
type=
'application/javascript'
src=
'/src/js/tutorial.js'
></script>
<script
type=
'application/javascript'
src=
'/src/js/scalablecanvas.js'
></script>
</head>
<body>
...
...
public/src/css/game.css
View file @
1d67575b
...
...
@@ -28,14 +28,14 @@
width
:
90%
;
height
:
25%
;
display
:
block
;
margin
:
auto
auto
30px
;
margin
:
0
auto
;
cursor
:
pointer
;
border
:
5px
solid
#ae7a26
;
border
:
.5vmin
solid
#ae7a26
;
background
:
rgb
(
255
,
255
,
255
);
color
:
black
;
font-family
:
TnT
;
font-size
:
5vmin
;
border-radius
:
1
0px
;
font-size
:
3.
5vmin
;
border-radius
:
1
.5vmin
;
}
#pause-menu
button
:hover
{
...
...
public/src/css/main.css
View file @
1d67575b
...
...
@@ -31,17 +31,22 @@ html, body{
}
.window
{
font-size
:
14pt
;
width
:
30%
;
height
:
30%
;
padding
:
30px
;
width
:
60vmin
;
height
:
23vmin
;
padding
:
3vmin
;
color
:
black
;
background
:
rgba
(
255
,
220
,
47
,
0.95
);
border
:
7px
outset
#f4ae00
;
position
:
relative
;
border
:
.5vmin
outset
#f4ae00
;
box-shadow
:
2px
2px
10px
black
;
top
:
35%
;
left
:
35%
;
margin
:
auto
;
position
:
fixed
;
top
:
0
;
right
:
0
;
bottom
:
0
;
left
:
0
;
display
:
flex
;
flex-direction
:
column
;
justify-content
:
space-between
;
}
...
...
@@ -59,7 +64,7 @@ html, body{
position
:
absolute
;
right
:
0
;
font-size
:
5vmin
;
margin
:
3
0px
30px
0px
0px
;
margin
:
3
vmin
3vmin
0px
0px
;
color
:
white
;
float
:
right
;
z-index
:
1
;
...
...
public/src/js/scalablecanvas.js
0 → 100644
View file @
1d67575b
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/view.js
View file @
1d67575b
...
...
@@ -3,12 +3,13 @@ class View{
this
.
controller
=
controller
this
.
bg
=
bg
this
.
diff
=
diff
this
.
canvas
=
document
.
getElementById
(
"
canvas
"
)
this
.
ctx
=
this
.
canvas
.
getContext
(
"
2d
"
)
this
.
winW
=
$
(
window
).
width
()
this
.
winH
=
$
(
window
).
height
()
this
.
canvas
=
new
ScalableCanvas
(
"
canvas
"
,
this
.
winW
,
this
.
winH
)
this
.
ctx
=
this
.
canvas
.
ctx
this
.
taikoSquareW
=
this
.
winW
/
4
this
.
slotX
=
this
.
taikoSquareW
+
100
...
...
@@ -27,7 +28,7 @@ class View{
this
.
currentBigDonFace
=
1
this
.
nextBeat
=
0
this
.
songTitle
=
t
his
.
t
itle
this
.
songTitle
=
title
this
.
songDifficulty
=
this
.
diff
.
split
(
"
.
"
).
slice
(
0
,
-
1
).
join
(
"
.
"
)
}
...
...
@@ -49,10 +50,11 @@ class View{
}
positionning
(){
this
.
winW
=
$
(
window
).
width
()
this
.
winH
=
$
(
window
).
height
()
this
.
canvas
.
width
=
this
.
winW
this
.
canvas
.
height
=
this
.
winH
this
.
canvas
.
rescale
()
this
.
canvas
.
resize
(
$
(
window
).
width
(),
$
(
window
).
height
())
this
.
winW
=
this
.
canvas
.
scaledWidth
this
.
winH
=
this
.
canvas
.
scaledHeight
this
.
barY
=
0.25
*
this
.
winH
this
.
barH
=
0.23
*
this
.
winH
this
.
lyricsBarH
=
0.2
*
this
.
barH
...
...
@@ -61,7 +63,7 @@ class View{
this
.
taikoX
=
this
.
taikoSquareW
*
0.76
-
this
.
taikoW
/
2
this
.
taikoY
=
this
.
barY
+
5
this
.
taikoSquareW
=
this
.
winW
/
4
this
.
slotX
=
this
.
taikoSquareW
+
100
this
.
slotX
=
this
.
taikoSquareW
+
this
.
barH
*
0.45
this
.
scoreSquareW
=
this
.
taikoSquareW
*
0.55
this
.
scoreSquareH
=
this
.
barH
*
0.25
this
.
circleSize
=
this
.
barH
*
0.15
...
...
@@ -84,7 +86,7 @@ class View{
this
.
HPBarColH
=
this
.
HPBarH
*
0.8
var
diffRatio
=
176
/
120
this
.
diffH
=
this
.
winH
*
0.16
this
.
diffW
=
this
.
diffH
*
diffRatio
this
.
diffW
=
this
.
diffH
*
diffRatio
this
.
diffX
=
this
.
taikoX
*
0.10
this
.
diffY
=
this
.
taikoY
*
1.05
+
this
.
taikoH
*
0.19
}
...
...
@@ -93,6 +95,8 @@ class View{
this
.
positionning
()
this
.
distanceForCircle
=
this
.
winW
-
this
.
slotX
this
.
ctx
.
clearRect
(
0
,
0
,
this
.
canvas
.
scaledWidth
,
this
.
canvas
.
scaledHeight
)
// Draw
this
.
drawBar
()
this
.
drawSlot
()
...
...
@@ -124,6 +128,8 @@ class View{
}
drawHPBar
(){
var
z
=
this
.
canvas
.
scale
var
bottomSquareX
=
this
.
taikoSquareW
var
borderSize
=
this
.
HPBarH
*
0.2
this
.
ctx
.
fillStyle
=
"
#000
"
...
...
@@ -139,13 +145,13 @@ class View{
bottomSquareX
+
borderSize
,
this
.
HPBarY
+
0.435
*
this
.
HPBarH
,
this
.
winW
-
bottomSquareX
-
borderSize
,
this
.
HPBarH
/
2
+
1
this
.
HPBarH
/
2
+
2
*
z
)
this
.
ctx
.
fillRect
(
bottomSquareX
,
this
.
HPBarY
+
0.68
*
this
.
HPBarH
,
this
.
HPBarW
*
0.8
,
this
.
HPBarH
/
4
+
1
this
.
HPBarH
/
4
+
2
*
z
)
this
.
ctx
.
arc
(
bottomSquareX
+
borderSize
,
...
...
@@ -200,13 +206,14 @@ class View{
}
drawMeasure
(
measure
){
var
z
=
this
.
canvas
.
scale
var
currentTime
=
this
.
controller
.
getEllapsedTime
().
ms
var
measureX
=
this
.
slotX
+
measure
.
speed
/
(
70
/
this
.
circleSize
)
*
(
measure
.
ms
-
currentTime
)
this
.
ctx
.
strokeStyle
=
"
#bab8b8
"
this
.
ctx
.
lineWidth
=
2
this
.
ctx
.
beginPath
()
this
.
ctx
.
moveTo
(
measureX
,
this
.
barY
+
5
)
this
.
ctx
.
lineTo
(
measureX
,
this
.
barY
+
this
.
barH
-
this
.
lyricsBarH
-
5
)
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
()
}
...
...
@@ -294,7 +301,7 @@ class View{
var
pointsText
=
this
.
controller
.
getGlobalScore
().
points
.
toString
().
split
(
""
)
for
(
var
i
in
pointsText
){
this
.
ctx
.
fillText
(
pointsText
[
i
],
this
.
scoreSquareW
-
2
0
+
glyph
*
(
i
-
pointsText
.
length
+
1
),
this
.
scoreSquareW
-
3
0
+
glyph
*
(
i
-
pointsText
.
length
+
1
),
this
.
barY
+
this
.
scoreSquareH
*
0.7
)
}
...
...
@@ -449,6 +456,8 @@ class View{
}
drawCircle
(
circle
,
circlePos
){
var
z
=
this
.
canvas
.
scale
var
fill
,
size
,
faceID
if
(
!
circlePos
){
var
currentTime
=
this
.
controller
.
getEllapsedTime
().
ms
...
...
@@ -540,11 +549,12 @@ class View{
}
drawTime
(){
var
z
=
this
.
canvas
.
scale
var
time
=
this
.
controller
.
getEllapsedTime
()
this
.
ctx
.
globalAlpha
=
0.7
this
.
ctx
.
fillStyle
=
"
#000
"
this
.
ctx
.
fillRect
(
this
.
winW
-
110
,
this
.
winH
-
60
,
this
.
winW
,
this
.
winH
)
this
.
ctx
.
fillRect
(
this
.
winW
-
110
*
z
,
this
.
winH
-
60
*
z
,
this
.
winW
,
this
.
winH
)
this
.
ctx
.
globalAlpha
=
1
this
.
ctx
.
fillStyle
=
"
#fff
"
...
...
@@ -556,9 +566,9 @@ class View{
this
.
ctx
.
font
=
"
normal
"
+
(
this
.
barH
/
12
)
+
"
px Kozuka
"
this
.
ctx
.
textAlign
=
"
right
"
this
.
ctx
.
fillText
(
formatedH
+
"
:
"
+
formatedM
+
"
:
"
+
formatedS
,
this
.
winW
-
10
,
this
.
winH
-
30
this
.
winW
-
10
*
z
,
this
.
winH
-
30
*
z
)
this
.
ctx
.
fillText
(
time
.
ms
,
this
.
winW
-
10
,
this
.
winH
-
10
)
this
.
ctx
.
fillText
(
time
.
ms
,
this
.
winW
-
10
*
z
,
this
.
winH
-
10
*
z
)
}
drawBar
(){
...
...
@@ -634,4 +644,4 @@ class View{
this
.
ctx
.
closePath
()
this
.
ctx
.
stroke
()
}
}
\ No newline at end of file
}
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