Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sejong25
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Tear of Sejong
sejong25
Commits
8c831d63
Commit
8c831d63
authored
Jun 27, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'wordspace'
# Conflicts: # js/WordObject.js # js/WordSpace.js
parents
3226ce18
9a631207
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
388 additions
and
22 deletions
+388
-22
index.html
index.html
+1
-1
Input.js
js/Input.js
+306
-2
WordObject.js
js/WordObject.js
+2
-1
WordSpace.js
js/WordSpace.js
+77
-17
main.js
js/main.js
+2
-1
No files found.
index.html
View file @
8c831d63
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<meta
charset=
"utf-8"
/>
<meta
charset=
"utf-8"
/>
<script
src=
"/socket.io/socket.io.js"
></script>
<script
src=
"/socket.io/socket.io.js"
></script>
<script
src=
"js/phaser.js"
></script>
<script
src=
"js/phaser.js"
></script>
<script
src=
"js/Background.js"
></script>
]
<script
src=
"js/Background.js"
></script>
<script
src=
"js/Input.js"
></script>
<script
src=
"js/Input.js"
></script>
<script
src=
"js/WordSpace.js"
></script>
<script
src=
"js/WordSpace.js"
></script>
<script
src=
"js/WordObject.js"
></script>
<script
src=
"js/WordObject.js"
></script>
...
...
js/Input.js
View file @
8c831d63
var
Input
=
Input
||
{};
var
Input
=
Input
||
{};
Input
.
input
=
[];
Input
.
input
=
[];
Input
.
convInput
=
""
;
// converted input
Input
.
convInput
=
''
;
// converted input
Input
.
isShifted
=
false
;
Input
.
pressCount
=
0
;
Input
.
justPressed
=
''
;
Input
.
reset
=
function
()
Input
.
reset
=
function
()
{
{
Input
.
input
=
[];
Input
.
input
=
[];
Input
.
convInput
=
[];
Input
.
inputField
.
text
.
setText
(
Input
.
convInput
);
}
}
// convert input to convInput
Input
.
convert
=
function
()
Input
.
convert
=
function
()
{
{
// convert input to convInput
// input -> krInput with vowels
let
krInput
=
""
;
let
vowels
=
[];
for
(
let
i
=
0
;
i
<
this
.
input
.
length
;
i
++
)
{
// 쌍자음, Shift쓰는 모음 체크
if
(
this
.
input
[
i
]
<
0
)
{
//console.log(-1 * this.input[i]);
switch
(
String
.
fromCharCode
(
-
1
*
this
.
input
[
i
]))
{
case
'
ㅂ
'
:
krInput
+=
'
ㅃ
'
;
break
;
case
'
ㅈ
'
:
krInput
+=
'
ㅉ
'
;
break
;
case
'
ㄷ
'
:
krInput
+=
'
ㄸ
'
;
break
;
case
'
ㄱ
'
:
krInput
+=
'
ㄲ
'
;
break
;
case
'
ㅅ
'
:
krInput
+=
'
ㅆ
'
;
break
;
case
'
ㅐ
'
:
krInput
+=
'
ㅒ
'
;
vowels
.
push
(
krInput
.
length
-
1
);
break
;
case
'
ㅔ
'
:
krInput
+=
'
ㅖ
'
;
vowels
.
push
(
krInput
.
length
-
1
);
break
;
default
:
console
.
log
(
"
[ERR] 이상한 단어가 쌍자음으로 들어옴.
"
);
break
;
}
}
// 모음쌍 체크
else
if
(
this
.
input
[
i
]
>=
'
ㅏ
'
.
charCodeAt
(
0
)
&&
this
.
input
[
i
+
1
]
>=
'
ㅏ
'
.
charCodeAt
(
0
))
{
switch
(
String
.
fromCharCode
(
this
.
input
[
i
])
+
String
.
fromCharCode
(
this
.
input
[
i
+
1
]))
{
case
'
ㅗㅏ
'
:
krInput
+=
'
ㅘ
'
;
vowels
.
push
(
krInput
.
length
-
1
);
i
++
;
break
;
case
'
ㅗㅐ
'
:
krInput
+=
'
ㅙ
'
;
vowels
.
push
(
krInput
.
length
-
1
);
i
++
;
break
;
case
'
ㅗㅣ
'
:
krInput
+=
'
ㅚ
'
;
vowels
.
push
(
krInput
.
length
-
1
);
i
++
;
break
;
case
'
ㅜㅓ
'
:
krInput
+=
'
ㅝ
'
;
vowels
.
push
(
krInput
.
length
-
1
);
i
++
;
break
;
case
'
ㅜㅔ
'
:
krInput
+=
'
ㅞ
'
;
vowels
.
push
(
krInput
.
length
-
1
);
i
++
;
break
;
case
'
ㅜㅣ
'
:
krInput
+=
'
ㅟ
'
;
vowels
.
push
(
krInput
.
length
-
1
);
i
++
;
break
;
case
'
ㅡㅣ
'
:
krInput
+=
'
ㅢ
'
;
vowels
.
push
(
krInput
.
length
-
1
);
i
++
;
break
;
default
:
krInput
+=
String
.
fromCharCode
(
this
.
input
[
i
]);
vowels
.
push
(
krInput
.
length
-
1
);
break
;
// 모음쌍을 만들지 못함.
}
}
// 나머지 자음 및 남는 모음들
else
{
krInput
+=
String
.
fromCharCode
(
this
.
input
[
i
]);
if
(
this
.
input
[
i
]
>=
'
ㅏ
'
.
charCodeAt
(
0
))
vowels
.
push
(
krInput
.
length
-
1
);
// 모음일 경우
}
}
//console.log(vowels);
this
.
convInput
=
""
;
let
vowelIdx
=
0
;
if
(
vowelIdx
===
vowels
.
length
)
this
.
convInput
=
krInput
;
// 모음이 없을때
else
// 모음이 존재할때
{
for
(
let
i
=
0
;
i
<=
vowels
[
vowelIdx
]
-
2
;
i
++
)
this
.
convInput
+=
krInput
[
i
];
while
(
vowelIdx
<
vowels
.
length
)
{
if
(
krInput
[
vowels
[
vowelIdx
]
-
1
]
>=
'
ㅏ
'
.
charCodeAt
(
0
))
// 모음 앞에 모음이 있을때
{
this
.
convInput
+=
krInput
[
vowels
[
vowelIdx
]];
vowelIdx
++
;
}
else
// 모음 앞에 자음이 있을때
{
var
first
=
this
.
convertToFirst
(
krInput
[
vowels
[
vowelIdx
]
-
1
]);
var
middle
=
krInput
[
vowels
[
vowelIdx
]];
var
last
=
0
;
if
(
vowelIdx
+
1
>=
vowels
.
length
)
// 다음 모음이 없을때
{
if
(
vowels
[
vowelIdx
]
+
1
<
krInput
.
length
)
// 다음 자음이 존재할 때
{
if
(
vowels
[
vowelIdx
]
+
2
<
krInput
.
length
)
// 다다음 자음이 존재할때
{
var
combLast
=
this
.
combineLast
(
krInput
[
vowels
[
vowelIdx
]
+
1
],
krInput
[
vowels
[
vowelIdx
]
+
2
]);
if
(
combLast
!=
null
)
// 뒤의 두 자음을 합칠수 있을 때
{
last
=
combLast
;
this
.
convInput
+=
String
.
fromCharCode
(
this
.
convertToCharCode
(
first
,
middle
,
last
));
for
(
var
i
=
vowels
[
vowelIdx
]
+
3
;
i
<
krInput
.
length
;
i
++
)
this
.
convInput
+=
krInput
[
i
];
vowelIdx
++
;
}
else
// 뒤의 두 자음을 합칠수 없을때
{
last
=
this
.
convertToLast
(
krInput
[
vowels
[
vowelIdx
]
+
1
]);
this
.
convInput
+=
String
.
fromCharCode
(
this
.
convertToCharCode
(
first
,
middle
,
last
));
for
(
var
i
=
vowels
[
vowelIdx
]
+
2
;
i
<
krInput
.
length
;
i
++
)
this
.
convInput
+=
krInput
[
i
];
vowelIdx
++
;
}
}
else
// 다다음 자음이 없을때
{
last
=
this
.
convertToLast
(
krInput
[
vowels
[
vowelIdx
]
+
1
]);
this
.
convInput
+=
String
.
fromCharCode
(
this
.
convertToCharCode
(
first
,
middle
,
last
));
vowelIdx
++
;
}
}
else
// 다음 글자가 없을때
{
this
.
convInput
+=
String
.
fromCharCode
(
this
.
convertToCharCode
(
first
,
middle
,
last
));
vowelIdx
++
;
}
}
else
// 다음 모음이 있을때
{
if
(
vowels
[
vowelIdx
+
1
]
-
vowels
[
vowelIdx
]
<=
2
)
// 다음 모음 사이에 자음이 0개거나 1개
{
this
.
convInput
+=
String
.
fromCharCode
(
this
.
convertToCharCode
(
first
,
middle
,
last
));
vowelIdx
++
;
}
else
if
(
vowels
[
vowelIdx
+
1
]
-
vowels
[
vowelIdx
]
===
3
)
// 다음 모음 사이에 자음이 2개
{
last
=
this
.
convertToLast
(
krInput
[
vowels
[
vowelIdx
]
+
1
]);
this
.
convInput
+=
String
.
fromCharCode
(
this
.
convertToCharCode
(
first
,
middle
,
last
));
vowelIdx
++
;
}
else
// 다음 모음 사이에 자음이 3개 이상
{
var
combLast
=
this
.
combineLast
(
krInput
[
vowels
[
vowelIdx
]
+
1
],
krInput
[
vowels
[
vowelIdx
]
+
2
]);
if
(
combLast
!=
null
)
// 뒤의 두 자음을 합칠수 있을 때
{
last
=
combLast
;
this
.
convInput
+=
String
.
fromCharCode
(
this
.
convertToCharCode
(
first
,
middle
,
last
));
for
(
var
i
=
vowels
[
vowelIdx
]
+
3
;
i
<
vowels
[
vowelIdx
+
1
]
-
1
;
i
++
)
this
.
convInput
+=
krInput
[
i
];
vowelIdx
++
;
}
else
// 뒤의 두 자음을 합칠수 없을때
{
last
=
this
.
convertToLast
(
krInput
[
vowels
[
vowelIdx
]
+
1
]);
this
.
convInput
+=
String
.
fromCharCode
(
this
.
convertToCharCode
(
first
,
middle
,
last
));
for
(
var
i
=
vowels
[
vowelIdx
]
+
2
;
i
<
vowels
[
vowelIdx
+
1
]
-
1
;
i
++
)
this
.
convInput
+=
krInput
[
i
];
vowelIdx
++
;
}
}
}
}
}
}
console
.
log
(
'
_____end_convert_____
'
);
}
Input
.
convertToLast
=
function
(
word
)
{
let
output
=
0
;
switch
(
word
)
{
case
'
ㄱ
'
:
output
=
1
;
break
;
case
'
ㄲ
'
:
output
=
2
;
break
;
case
'
ㄴ
'
:
output
=
4
;
break
;
case
'
ㄷ
'
:
output
=
7
;
break
;
case
'
ㄹ
'
:
output
=
8
;
break
;
case
'
ㅁ
'
:
output
=
16
;
break
;
case
'
ㅂ
'
:
output
=
17
;
break
;
case
'
ㅅ
'
:
output
=
19
;
break
;
case
'
ㅆ
'
:
output
=
20
;
break
;
case
'
ㅇ
'
:
output
=
21
;
break
;
case
'
ㅈ
'
:
output
=
22
;
break
;
case
'
ㅊ
'
:
output
=
23
;
break
;
case
'
ㅋ
'
:
output
=
24
;
break
;
case
'
ㅌ
'
:
output
=
25
;
break
;
case
'
ㅍ
'
:
output
=
26
;
break
;
case
'
ㅎ
'
:
output
=
27
;
break
;
default
:
break
;
}
return
output
;
}
Input
.
convertToCharCode
=
function
(
first
,
middle
,
last
)
{
// 'last' and 'first' must be code of last words
return
0xac00
+
28
*
21
*
first
+
28
*
(
middle
.
charCodeAt
(
0
)
-
'
ㅏ
'
.
charCodeAt
(
0
))
+
last
;
}
Input
.
combineLast
=
function
(
left
,
right
)
{
if
(
right
.
charCodeAt
(
0
)
<=
'
ㅎ
'
.
charCodeAt
(
0
))
{
let
output
=
null
;
switch
(
left
+
'
,
'
+
right
)
{
case
'
ㄱ,ㅅ
'
:
output
=
3
;
break
;
case
'
ㄴ,ㅈ
'
:
output
=
5
;
break
;
case
'
ㄴ,ㅎ
'
:
output
=
6
;
break
;
case
'
ㄹ,ㄱ
'
:
output
=
9
;
break
;
case
'
ㄹ,ㅁ
'
:
output
=
10
;
break
;
case
'
ㄹ,ㅂ
'
:
output
=
11
;
break
;
case
'
ㄹ,ㅅ
'
:
output
=
12
;
break
;
case
'
ㄹ,ㅌ
'
:
output
=
13
;
break
;
case
'
ㄹ,ㅍ
'
:
output
=
14
;
break
;
case
'
ㄹ,ㅎ
'
:
output
=
15
;
break
;
case
'
ㅂ,ㅅ
'
:
output
=
18
;
break
;
default
:
break
;
}
return
output
;
}
else
return
null
;
}
// 나중에 바꿀 계획 있음
Input
.
convertToFirst
=
function
(
word
)
{
let
output
=
0
;
switch
(
word
)
{
case
'
ㄱ
'
:
output
=
0
;
break
;
case
'
ㄲ
'
:
output
=
1
;
break
;
case
'
ㄴ
'
:
output
=
2
;
break
;
case
'
ㄷ
'
:
output
=
3
;
break
;
case
'
ㄸ
'
:
output
=
4
;
break
;
case
'
ㄹ
'
:
output
=
5
;
break
;
case
'
ㅁ
'
:
output
=
6
;
break
;
case
'
ㅂ
'
:
output
=
7
;
break
;
case
'
ㅃ
'
:
output
=
8
;
break
;
case
'
ㅅ
'
:
output
=
9
;
break
;
case
'
ㅆ
'
:
output
=
10
;
break
;
case
'
ㅇ
'
:
output
=
11
;
break
;
case
'
ㅈ
'
:
output
=
12
;
break
;
case
'
ㅉ
'
:
output
=
13
;
break
;
case
'
ㅊ
'
:
output
=
14
;
break
;
case
'
ㅋ
'
:
output
=
15
;
break
;
case
'
ㅌ
'
:
output
=
16
;
break
;
case
'
ㅍ
'
:
output
=
17
;
break
;
case
'
ㅎ
'
:
output
=
18
;
break
;
default
:
break
;
}
return
output
;
}
}
Input
.
isEqual
=
function
(
inputWord
,
wordText
)
{
return
inputWord
===
wordText
;
}
Input
.
isEqual
=
function
(
inputWord
,
wordText
)
{
return
inputWord
===
wordText
;
}
...
@@ -35,9 +262,86 @@ Input.inputField =
...
@@ -35,9 +262,86 @@ Input.inputField =
{
{
this
.
background
=
scene
.
add
.
sprite
(
400
,
500
,
'
inputFieldBackground
'
).
setScale
(
0.2
);
this
.
background
=
scene
.
add
.
sprite
(
400
,
500
,
'
inputFieldBackground
'
).
setScale
(
0.2
);
this
.
text
=
scene
.
add
.
text
(
400
,
500
,
"
안녕하세요
"
,
{
font
:
'
15pt 궁서
'
}).
setOrigin
(
0.5
,
0.5
).
setColor
(
'
#000000
'
);
this
.
text
=
scene
.
add
.
text
(
400
,
500
,
"
안녕하세요
"
,
{
font
:
'
15pt 궁서
'
}).
setOrigin
(
0.5
,
0.5
).
setColor
(
'
#000000
'
);
scene
.
input
.
keyboard
.
on
(
'
keyup
'
,
function
()
{
Input
.
pressCount
--
;
Input
.
justPressed
=
''
})
scene
.
input
.
keyboard
.
on
(
'
keydown-SHIFT
'
,
function
()
{
Input
.
isShifted
=
true
});
scene
.
input
.
keyboard
.
on
(
'
keyup-SHIFT
'
,
function
()
{
Input
.
isShifted
=
false
});
scene
.
input
.
keyboard
.
on
(
'
keydown-DELETE
'
,
function
()
{
Input
.
reset
()});
scene
.
input
.
keyboard
.
on
(
'
keydown-BACKSPACE
'
,
function
()
{
if
(
Input
.
input
.
length
>
0
)
{
Input
.
input
.
pop
();
Input
.
convert
();
Input
.
inputField
.
text
.
setText
(
Input
.
convInput
);
}
});
scene
.
input
.
keyboard
.
on
(
'
keydown-ENTER
'
,
function
()
{
WordSpace
.
findWord
(
Input
.
convInput
);
Input
.
reset
();
});
// upside 10 keys
scene
.
input
.
keyboard
.
on
(
'
keydown-Q
'
,
function
()
{
Input
.
pushInput
(
'
ㅂ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-W
'
,
function
()
{
Input
.
pushInput
(
'
ㅈ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-E
'
,
function
()
{
Input
.
pushInput
(
'
ㄷ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-R
'
,
function
()
{
Input
.
pushInput
(
'
ㄱ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-T
'
,
function
()
{
Input
.
pushInput
(
'
ㅅ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-Y
'
,
function
()
{
Input
.
pushInput
(
'
ㅛ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-U
'
,
function
()
{
Input
.
pushInput
(
'
ㅕ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-I
'
,
function
()
{
Input
.
pushInput
(
'
ㅑ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-O
'
,
function
()
{
Input
.
pushInput
(
'
ㅐ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-P
'
,
function
()
{
Input
.
pushInput
(
'
ㅔ
'
)});
// middleside 9 keys
scene
.
input
.
keyboard
.
on
(
'
keydown-A
'
,
function
()
{
Input
.
pushInput
(
'
ㅁ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-S
'
,
function
()
{
Input
.
pushInput
(
'
ㄴ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-D
'
,
function
()
{
Input
.
pushInput
(
'
ㅇ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-F
'
,
function
()
{
Input
.
pushInput
(
'
ㄹ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-G
'
,
function
()
{
Input
.
pushInput
(
'
ㅎ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-H
'
,
function
()
{
Input
.
pushInput
(
'
ㅗ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-J
'
,
function
()
{
Input
.
pushInput
(
'
ㅓ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-K
'
,
function
()
{
Input
.
pushInput
(
'
ㅏ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-L
'
,
function
()
{
Input
.
pushInput
(
'
ㅣ
'
)});
// downside 7 keys
scene
.
input
.
keyboard
.
on
(
'
keydown-Z
'
,
function
()
{
Input
.
pushInput
(
'
ㅋ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-X
'
,
function
()
{
Input
.
pushInput
(
'
ㅌ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-C
'
,
function
()
{
Input
.
pushInput
(
'
ㅊ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-V
'
,
function
()
{
Input
.
pushInput
(
'
ㅍ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-B
'
,
function
()
{
Input
.
pushInput
(
'
ㅠ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-N
'
,
function
()
{
Input
.
pushInput
(
'
ㅜ
'
)});
scene
.
input
.
keyboard
.
on
(
'
keydown-M
'
,
function
()
{
Input
.
pushInput
(
'
ㅡ
'
)});
},
},
loadImage
:
function
(
scene
)
loadImage
:
function
(
scene
)
{
{
scene
.
load
.
image
(
'
inputFieldBackground
'
,
'
assets/inputFieldBackground.png
'
);
scene
.
load
.
image
(
'
inputFieldBackground
'
,
'
assets/inputFieldBackground.png
'
);
}
}
}
Input
.
pushInput
=
function
(
inputKey
)
{
if
(
this
.
justPressed
!=
inputKey
)
{
this
.
justPressed
=
inputKey
;
let
output
;
if
(
Input
.
isShifted
)
{
switch
(
inputKey
)
{
case
'
ㅂ
'
:
output
=
-
1
*
'
ㅂ
'
.
charCodeAt
(
0
);
break
;
case
'
ㅈ
'
:
output
=
-
1
*
'
ㅈ
'
.
charCodeAt
(
0
);
break
;
case
'
ㄷ
'
:
output
=
-
1
*
'
ㄷ
'
.
charCodeAt
(
0
);
break
;
case
'
ㄱ
'
:
output
=
-
1
*
'
ㄱ
'
.
charCodeAt
(
0
);
break
;
case
'
ㅅ
'
:
output
=
-
1
*
'
ㅅ
'
.
charCodeAt
(
0
);
break
;
case
'
ㅐ
'
:
output
=
-
1
*
'
ㅐ
'
.
charCodeAt
(
0
);
break
;
case
'
ㅔ
'
:
output
=
-
1
*
'
ㅔ
'
.
charCodeAt
(
0
);
break
;
default
:
output
=
inputKey
.
charCodeAt
(
0
);
break
;
}
}
else
output
=
inputKey
.
charCodeAt
(
0
);
Input
.
input
.
push
(
output
);
console
.
log
(
Input
.
input
);
Input
.
convert
();
Input
.
inputField
.
text
.
setText
(
Input
.
convInput
);
this
.
pressCount
++
;
}
}
}
\ No newline at end of file
js/WordObject.js
View file @
8c831d63
...
@@ -31,6 +31,7 @@ class WordObject
...
@@ -31,6 +31,7 @@ class WordObject
destroy
()
destroy
()
{
{
console
.
log
(
this
.
generationCode
+
'
:
'
+
this
.
wordText
+
'
destroyed
'
);
this
.
wordObj
.
destroy
();
this
.
wordObj
.
destroy
();
const
groupIdx
=
WordSpace
.
wordGroup
.
findIndex
(
function
(
item
)
{
return
this
.
isEqualObject
(
item
.
generationCode
)},
this
);
const
groupIdx
=
WordSpace
.
wordGroup
.
findIndex
(
function
(
item
)
{
return
this
.
isEqualObject
(
item
.
generationCode
)},
this
);
if
(
groupIdx
>
-
1
)
WordSpace
.
wordGroup
.
splice
(
groupIdx
,
1
);
if
(
groupIdx
>
-
1
)
WordSpace
.
wordGroup
.
splice
(
groupIdx
,
1
);
...
@@ -49,5 +50,5 @@ class WordObject
...
@@ -49,5 +50,5 @@ class WordObject
getWordWeight
()
{
return
this
.
wordWeight
;
}
getWordWeight
()
{
return
this
.
wordWeight
;
}
isEqualObject
(
_generationCode
)
{
return
_generationCode
===
this
.
_
generationCode
;
}
isEqualObject
(
_generationCode
)
{
return
_generationCode
===
this
.
generationCode
;
}
}
}
\ No newline at end of file
js/WordSpace.js
View file @
8c831d63
...
@@ -15,26 +15,65 @@ WordSpace.wordPhysicsGroup = null;
...
@@ -15,26 +15,65 @@ WordSpace.wordPhysicsGroup = null;
WordSpace
.
gravityPoint
=
{
x
:
400
,
y
:
300
};
WordSpace
.
gravityPoint
=
{
x
:
400
,
y
:
300
};
WordSpace
.
wordCycle
=
null
;
WordSpace
.
attackGauge
=
WordSpace
.
resetCycle
=
function
(
scene
,
_delay
)
{
{
var
option
=
value
:
0
,
add
:
function
(
plus
)
{
{
delay
:
_delay
,
if
(
this
.
value
+
plus
>
11
)
this
.
value
=
11
;
callback
:
function
()
else
this
.
value
+=
plus
;
{
this
.
text
.
setText
(
'
게이지:
'
+
this
.
value
.
toFixed
(
1
));
WordSpace
.
generateWord
(
this
)
},
},
sub
:
function
(
minus
)
callbackScope
:
scene
,
loop
:
true
};
if
(
this
.
wordCycle
!=
null
)
{
{
this
.
wordCycle
=
this
.
wordCycle
.
reset
(
option
);
if
(
this
.
value
-
minus
<
0
)
this
.
value
=
0
;
}
else
this
.
value
-=
minus
;
else
this
.
text
.
setText
(
'
게이지:
'
+
this
.
value
.
toFixed
(
1
));
},
resetValue
:
function
()
{
this
.
value
=
0
;},
cutValue
:
function
(
cutOut
)
{
this
.
value
*=
(
1
-
cutOut
);},
resetCycle
:
function
(
scene
)
{
{
this
.
wordCycle
=
scene
.
time
.
addEvent
(
option
);
var
option
=
{
delay
:
300
,
callback
:
function
()
{
WordSpace
.
attackGauge
.
sub
(
0.1
);
},
loop
:
true
};
this
.
currentCycle
=
scene
.
time
.
addEvent
(
option
);
this
.
text
=
scene
.
add
.
text
(
100
,
100
,
'
게이지:
'
+
this
.
value
.
toFixed
(
1
)).
setColor
(
'
#ffffff
'
);
},
pauseCycle
:
function
(
bool
)
{
this
.
currentCycle
.
paused
=
bool
;}
// showValue: 아래쪽에 바의 길이로 게이지 표시, 색으로 게이지의 강도 표현
}
WordSpace
.
wordCycle
=
{
currentCycle
:
null
,
resetCycle
:
function
(
scene
,
_delay
)
{
var
option
=
{
delay
:
_delay
,
callback
:
function
()
{
WordSpace
.
generateWord
(
this
)
},
callbackScope
:
scene
,
loop
:
true
};
if
(
this
.
currentCycle
!=
null
)
{
this
.
currentCycle
=
this
.
currentCycle
.
reset
(
option
);
}
else
{
this
.
currentCycle
=
scene
.
time
.
addEvent
(
option
);
}
}
}
}
}
...
@@ -59,8 +98,9 @@ WordSpace.generateWord = function(scene)
...
@@ -59,8 +98,9 @@ WordSpace.generateWord = function(scene)
function
gameOver
()
function
gameOver
()
{
{
this
.
wordCycle
.
paused
=
true
;
this
.
wordCycle
.
currentCycle
.
paused
=
true
;
//To Do
//To Do
console
.
log
(
'
defeat
'
);
}
}
//게임 오버 판정을 위한 타이머
//게임 오버 판정을 위한 타이머
...
@@ -72,4 +112,24 @@ WordSpace.setGameOverTimer = function()
...
@@ -72,4 +112,24 @@ WordSpace.setGameOverTimer = function()
this
.
gameOverTimer
=
setTimeout
(
gameOver
.
bind
(
this
),
this
.
defeatTime
);
this
.
gameOverTimer
=
setTimeout
(
gameOver
.
bind
(
this
),
this
.
defeatTime
);
isTimerOn
=
true
;
isTimerOn
=
true
;
}
}
}
WordSpace
.
findWord
=
function
(
word
)
{
var
found
=
WordSpace
.
wordGroup
.
find
(
function
(
element
)
{
return
Input
.
isEqual
(
word
,
element
.
wordText
);
});
if
(
found
!=
undefined
)
{
switch
(
found
.
wordGrade
)
// 이부분 나중에 더 효율적으로 바꿀수있지 않을까
{
case
0
:
WordSpace
.
attackGauge
.
add
(
2.5
);
break
;
case
1
:
WordSpace
.
attackGauge
.
add
(
1.5
);
break
;
case
2
:
WordSpace
.
attackGauge
.
add
(
0.9
);
break
;
case
3
:
WordSpace
.
attackGauge
.
add
(
0.5
);
break
;
default
:
console
.
log
(
'
[ERR] wrong grade of word
'
);
break
;
}
found
.
destroy
();
}
}
}
\ No newline at end of file
js/main.js
View file @
8c831d63
...
@@ -31,7 +31,8 @@ function create()
...
@@ -31,7 +31,8 @@ function create()
BackGround
.
drawBrain
(
this
);
BackGround
.
drawBrain
(
this
);
Input
.
inputField
.
generate
(
this
);
Input
.
inputField
.
generate
(
this
);
WordSpace
.
wordPhysicsGroup
=
this
.
physics
.
add
.
group
();
WordSpace
.
wordPhysicsGroup
=
this
.
physics
.
add
.
group
();
WordSpace
.
resetCycle
(
this
,
2000
);
WordSpace
.
wordCycle
.
resetCycle
(
this
,
2000
);
WordSpace
.
attackGauge
.
resetCycle
(
this
);
}
}
function
update
()
function
update
()
...
...
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