Fix: practice screen
This commit is contained in:
@@ -24,15 +24,12 @@ class TypingPractice {
|
||||
|
||||
|
||||
// typing content
|
||||
var typingAreaPositionY = 260;
|
||||
var bar = game.add.graphics();
|
||||
let typingAreaPositionY = 160;
|
||||
let bar = game.add.graphics();
|
||||
bar.beginFill(0x000000, 0.2);
|
||||
bar.drawRect(0, typingAreaPositionY, GAME_SCREEN_SIZE.x, 120);
|
||||
|
||||
if(isTypingWordStage())
|
||||
textStyleBasic.font = "bold 84px Arial";
|
||||
else // Sentence stage
|
||||
textStyleBasic.font = "bold 48px Arial";
|
||||
textStyleBasic.font = "bold 84px Arial";
|
||||
|
||||
this.textTypingContent = game.add.text(0, 2, "test", textStyleBasic)
|
||||
.setTextBounds(0, typingAreaPositionY, GAME_SCREEN_SIZE.x, 120)
|
||||
@@ -41,47 +38,17 @@ class TypingPractice {
|
||||
|
||||
textStyleBasic.font = "32px Arial";
|
||||
|
||||
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||
this.textTypingContentsDone = [];
|
||||
this.textTypingRecordsDone = [];
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
this.textTypingContentsDone[i] = game.add.text(0, 2, "test", textStyleBasic)
|
||||
.setTextBounds(0, typingAreaPositionY - 50 - i * 50, GAME_SCREEN_SIZE.x, 40)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.addColor(textDoneColor[i], 0);
|
||||
|
||||
var scorePositionX = 780;
|
||||
if(isTypingWordStage())
|
||||
scorePositionX = 600;
|
||||
|
||||
this.textTypingRecordsDone[i] = game.add.text(0, 2, "", textStyleBasic)
|
||||
.setTextBounds(scorePositionX, typingAreaPositionY - 50 - i * 50, 200, 40)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.addColor(textDoneColor[i], 0);
|
||||
|
||||
}
|
||||
|
||||
var textPreviewColor = [ '#999999', '#888888', '#777777' ];
|
||||
this.textTypingContentPreview = [];
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
this.textTypingContentPreview[i] = game.add.text(0, 2, "test", textStyleBasic)
|
||||
.setTextBounds(0, typingAreaPositionY + 130 + i * 50, GAME_SCREEN_SIZE.x, 40)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.addColor(textPreviewColor[i], 0);
|
||||
}
|
||||
|
||||
|
||||
// input text
|
||||
this.inputTextContent = new InputTypeText(game.world.centerX, typingAreaPositionY + 360);
|
||||
this.inputTextContent.anchor.set(0.5);
|
||||
this.inputTextContent.canvasInput.value('');
|
||||
this.inputTextContent.canvasInput.focus();
|
||||
// inputTextContent.canvasInput._onkeydown = this.checkInputText;
|
||||
// inputTextContent.canvasInput._onkeyup = function() {
|
||||
this.inputTextContent.canvasInput._onkeyup = function() {
|
||||
self.checkTypingContents(event);
|
||||
}
|
||||
let textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||
this.textTypingContentsDone = game.add.text(0, 2, "test", textStyleBasic)
|
||||
.setTextBounds(0, typingAreaPositionY - 50, GAME_SCREEN_SIZE.x, 40)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.addColor(textDoneColor[0], 0);
|
||||
|
||||
let textPreviewColor = [ '#999999', '#888888', '#777777' ];
|
||||
this.textTypingContentPreview = game.add.text(0, 2, "test", textStyleBasic)
|
||||
.setTextBounds(0, typingAreaPositionY + 130, GAME_SCREEN_SIZE.x, 40)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.addColor(textPreviewColor[0], 0);
|
||||
|
||||
// bottom
|
||||
let screenBottom = new ScreenBottom();
|
||||
@@ -91,41 +58,18 @@ class TypingPractice {
|
||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||
|
||||
|
||||
this.startGame();
|
||||
game.input.keyboard.addCallbacks(this, null, null, this.keyPress);
|
||||
// this.startGame();
|
||||
// this.countDown();
|
||||
}
|
||||
|
||||
/*
|
||||
countDown() {
|
||||
const style = { font: "bold 200px Arial", fill: "#fff", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
this.countDownText = game.add.text(0, 0, "", style);
|
||||
this.countDownText.setTextBounds(0, 0, game.world.width, game.world.height);
|
||||
this.countDownText.stroke = "#333";
|
||||
this.countDownText.strokeThickness = 50;
|
||||
|
||||
this.countDownNumber = 3;
|
||||
if(isDebugMode())
|
||||
this.countDownNumber = 1;
|
||||
this.tweenCountDown();
|
||||
keyPress(char) {
|
||||
// self.checkTypingContents(event);
|
||||
console.log(char);
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.SHIFT))
|
||||
console.log("shift is pressed");
|
||||
}
|
||||
|
||||
tweenCountDown() {
|
||||
if(this.countDownNumber === 0) {
|
||||
this.startGame();
|
||||
return;
|
||||
}
|
||||
|
||||
this.countDownText.text = this.countDownNumber.toString();
|
||||
this.countDownText.alpha = 1;
|
||||
|
||||
let countDownTween = game.add.tween(this.countDownText);
|
||||
countDownTween.to( { alpha: 0 }, GAME_SCREEN_SIZE.x, Phaser.Easing.Linear.None, true);
|
||||
countDownTween.onComplete.add(this.tweenCountDown, this);
|
||||
|
||||
this.countDownNumber--;
|
||||
}
|
||||
*/
|
||||
|
||||
startGame() {
|
||||
this.showTypingPracticeContents();
|
||||
this.showPlayingWordNumber();
|
||||
@@ -147,7 +91,7 @@ class TypingPractice {
|
||||
|
||||
initTypingData() {
|
||||
this.typingContents = this.getTypingPracticeContents();
|
||||
var randomContents = Phaser.ArrayUtils.shuffle(this.typingContents);
|
||||
let randomContents = Phaser.ArrayUtils.shuffle(this.typingContents);
|
||||
this.wordCountForStage = TypingPractice.WORD_COUNT_FOR_STAGE;
|
||||
if(isDebugMode())
|
||||
this.wordCountForStage = 3;
|
||||
@@ -165,14 +109,14 @@ class TypingPractice {
|
||||
|
||||
|
||||
getTypingPracticeContents() {
|
||||
var TypingPracticeContents = this.loadTestContent();
|
||||
let TypingPracticeContents = this.loadTestContent();
|
||||
// console.log('playingStageData.language : ' + playingStageData.language);
|
||||
// console.log('playingStageData.level : ' + playingStageData.level);
|
||||
// console.log('TypingPracticeContents : ' + TypingPracticeContents);
|
||||
|
||||
this.typingRecordForLines = [];
|
||||
this.typingElapsedTime = [];
|
||||
for(var i = 0; i < TypingPracticeContents.length; i++) {
|
||||
for(let i = 0; i < TypingPracticeContents.length; i++) {
|
||||
this.typingRecordForLines[i] = 0;
|
||||
this.typingElapsedTime[i] = 0;
|
||||
}
|
||||
@@ -187,7 +131,7 @@ class TypingPractice {
|
||||
else if(isTypingPracticeStage())
|
||||
appName = sessionStorageManager.playingAppName.substring(9);
|
||||
|
||||
var testContent = [];
|
||||
let testContent = [];
|
||||
switch(appName) {
|
||||
case "korean_basic":
|
||||
testContent = koreanBasicWordList;
|
||||
@@ -250,8 +194,8 @@ class TypingPractice {
|
||||
}
|
||||
|
||||
showTypingPracticeContents() {
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
var doneIndex = this.typingIndex - i - 1;
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
let doneIndex = this.typingIndex - i - 1;
|
||||
if(doneIndex < 0) {
|
||||
this.textTypingContentsDone[i].text = "";
|
||||
this.textTypingRecordsDone[i].text = "";
|
||||
@@ -268,8 +212,8 @@ class TypingPractice {
|
||||
|
||||
this.textTypingContent.text = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
var previewIndex = this.typingIndex + i + 1;
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
let previewIndex = this.typingIndex + i + 1;
|
||||
if(previewIndex < this.typingRandomContents.length)
|
||||
this.textTypingContentPreview[i].text = this.typingRandomContents[previewIndex];
|
||||
else
|
||||
@@ -286,8 +230,8 @@ class TypingPractice {
|
||||
checkTypingContents(evnet) {
|
||||
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
||||
// console.log("### enter ###");
|
||||
var inputContent = this.inputTextContent.canvasInput.value();
|
||||
var typingContent = this.typingRandomContents[this.typingIndex];
|
||||
let inputContent = this.inputTextContent.canvasInput.value();
|
||||
let typingContent = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
if(inputContent == typingContent) {
|
||||
this.calculateTypingRecord(typingContent);
|
||||
@@ -310,8 +254,8 @@ class TypingPractice {
|
||||
}
|
||||
|
||||
showTypingContentHighlight() {
|
||||
var typingContent = this.typingRandomContents[this.typingIndex];
|
||||
var inputContent = this.inputTextContent.canvasInput.value();
|
||||
let typingContent = this.typingRandomContents[this.typingIndex];
|
||||
let inputContent = this.inputTextContent.canvasInput.value();
|
||||
|
||||
this.textTypingContent.clearColors();
|
||||
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0);
|
||||
@@ -319,8 +263,8 @@ class TypingPractice {
|
||||
if(typingContent == null)
|
||||
return;
|
||||
|
||||
var typingContentLength = typingContent.length;
|
||||
for(var i = 0; i < typingContentLength; i++) {
|
||||
let typingContentLength = typingContent.length;
|
||||
for(let i = 0; i < typingContentLength; i++) {
|
||||
// console.log("typingContent.charAt(i) : " + typingContent.charAt(i));
|
||||
// console.log("inputContent.charAt(i) : " + inputContent.charAt(i));
|
||||
|
||||
@@ -338,21 +282,21 @@ class TypingPractice {
|
||||
this.timeTypingEnd = game.time.elapsedSince(0);
|
||||
// console.log('this.timeTypingEnd : ' + this.timeTypingEnd);
|
||||
|
||||
var elapsedTimeMS = this.timeTypingEnd - this.timeTypingStart;
|
||||
let elapsedTimeMS = this.timeTypingEnd - this.timeTypingStart;
|
||||
// console.log('elapsedTimeMS : ' + elapsedTimeMS);
|
||||
|
||||
var typingContentLength = StringUtil.getUnicodeAlphabetCount(typingContent);
|
||||
let typingContentLength = StringUtil.getUnicodeAlphabetCount(typingContent);
|
||||
// console.log('typingContentLength : ' + typingContentLength);
|
||||
var typingContentPlusEnterCount = typingContentLength + TypingPractice.TYPING_COUNT_PLUS_ENTER;
|
||||
let typingContentPlusEnterCount = typingContentLength + TypingPractice.TYPING_COUNT_PLUS_ENTER;
|
||||
|
||||
var typingRecord = (typingContentPlusEnterCount + TypingPractice.TYPING_COUNT_PLUS_ENTER) * 60000 / elapsedTimeMS;
|
||||
let typingRecord = (typingContentPlusEnterCount + TypingPractice.TYPING_COUNT_PLUS_ENTER) * 60000 / elapsedTimeMS;
|
||||
|
||||
this.typingElapsedTime[this.typingIndex] = elapsedTimeMS;
|
||||
this.typingLetterCountTotal += typingContentPlusEnterCount;
|
||||
this.typingRecordForLines[this.typingIndex] = typingRecord;
|
||||
// console.log(this.typingRecordForLines[this.typingIndex]);
|
||||
|
||||
var typingElapsedTimeTotal = 0;
|
||||
let typingElapsedTimeTotal = 0;
|
||||
for(let i = 0; i <= this.typingIndex; i++) {
|
||||
// console.log('i : ' + i + ' - time : ' + this.typingElapsedTime[i]);
|
||||
typingElapsedTimeTotal += this.typingElapsedTime[i];
|
||||
@@ -382,7 +326,7 @@ class TypingPractice {
|
||||
|
||||
setTimeTypingStart() {
|
||||
this.timeTypingStart = game.time.elapsedSince(0);
|
||||
var timeGap = this.timeTypingStart - this.timeTypingEnd;
|
||||
let timeGap = this.timeTypingStart - this.timeTypingEnd;
|
||||
|
||||
if(timeGap < 50)
|
||||
return;
|
||||
|
||||
@@ -25,8 +25,8 @@ class TypingTest {
|
||||
|
||||
|
||||
// typing content
|
||||
var typingAreaPositionY = 260;
|
||||
var bar = game.add.graphics();
|
||||
let typingAreaPositionY = 260;
|
||||
let bar = game.add.graphics();
|
||||
bar.beginFill(0x000000, 0.2);
|
||||
bar.drawRect(0, typingAreaPositionY, GAME_SCREEN_SIZE.x, 120);
|
||||
|
||||
@@ -42,16 +42,16 @@ class TypingTest {
|
||||
|
||||
textStyleBasic.font = "32px Arial";
|
||||
|
||||
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||
let textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||
this.textTypingContentsDone = [];
|
||||
this.textTypingRecordsDone = [];
|
||||
for(var i = 0; i < TypingTest.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
for(let i = 0; i < TypingTest.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
this.textTypingContentsDone[i] = game.add.text(0, 2, "test", textStyleBasic)
|
||||
.setTextBounds(0, typingAreaPositionY - 50 - i * 50, GAME_SCREEN_SIZE.x, 40)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.addColor(textDoneColor[i], 0);
|
||||
|
||||
var scorePositionX = 780;
|
||||
let scorePositionX = 780;
|
||||
if(isTypingWordStage())
|
||||
scorePositionX = 600;
|
||||
|
||||
@@ -62,9 +62,9 @@ class TypingTest {
|
||||
|
||||
}
|
||||
|
||||
var textPreviewColor = [ '#999999', '#888888', '#777777' ];
|
||||
let textPreviewColor = [ '#999999', '#888888', '#777777' ];
|
||||
this.textTypingContentPreview = [];
|
||||
for(var i = 0; i < TypingTest.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
for(let i = 0; i < TypingTest.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
this.textTypingContentPreview[i] = game.add.text(0, 2, "test", textStyleBasic)
|
||||
.setTextBounds(0, typingAreaPositionY + 130 + i * 50, GAME_SCREEN_SIZE.x, 40)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
@@ -150,7 +150,7 @@ class TypingTest {
|
||||
|
||||
initTypingData() {
|
||||
this.typingContents = this.getTypingTestContents();
|
||||
var randomContents = Phaser.ArrayUtils.shuffle(this.typingContents);
|
||||
let randomContents = Phaser.ArrayUtils.shuffle(this.typingContents);
|
||||
this.wordCountForStage = TypingTest.WORD_COUNT_FOR_STAGE;
|
||||
if(isDebugMode())
|
||||
this.wordCountForStage = 3;
|
||||
@@ -168,14 +168,14 @@ class TypingTest {
|
||||
|
||||
|
||||
getTypingTestContents() {
|
||||
var typingTestContents = this.loadTestContent();
|
||||
let typingTestContents = this.loadTestContent();
|
||||
// console.log('playingStageData.language : ' + playingStageData.language);
|
||||
// console.log('playingStageData.level : ' + playingStageData.level);
|
||||
// console.log('typingTestContents : ' + typingTestContents);
|
||||
|
||||
this.typingRecordForLines = [];
|
||||
this.typingElapsedTime = [];
|
||||
for(var i = 0; i < typingTestContents.length; i++) {
|
||||
for(let i = 0; i < typingTestContents.length; i++) {
|
||||
this.typingRecordForLines[i] = 0;
|
||||
this.typingElapsedTime[i] = 0;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ class TypingTest {
|
||||
else if(isTypingPracticeStage())
|
||||
appName = sessionStorageManager.playingAppName.substring(9);
|
||||
|
||||
var testContent = [];
|
||||
let testContent = [];
|
||||
switch(appName) {
|
||||
case "korean_basic":
|
||||
testContent = koreanBasicWordList;
|
||||
@@ -253,8 +253,8 @@ class TypingTest {
|
||||
}
|
||||
|
||||
showTypingTestContents() {
|
||||
for(var i = 0; i < TypingTest.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
var doneIndex = this.typingIndex - i - 1;
|
||||
for(let i = 0; i < TypingTest.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
let doneIndex = this.typingIndex - i - 1;
|
||||
if(doneIndex < 0) {
|
||||
this.textTypingContentsDone[i].text = "";
|
||||
this.textTypingRecordsDone[i].text = "";
|
||||
@@ -271,8 +271,8 @@ class TypingTest {
|
||||
|
||||
this.textTypingContent.text = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
for(var i = 0; i < TypingTest.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
var previewIndex = this.typingIndex + i + 1;
|
||||
for(let i = 0; i < TypingTest.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
let previewIndex = this.typingIndex + i + 1;
|
||||
if(previewIndex < this.typingRandomContents.length)
|
||||
this.textTypingContentPreview[i].text = this.typingRandomContents[previewIndex];
|
||||
else
|
||||
@@ -289,8 +289,8 @@ class TypingTest {
|
||||
checkTypingContents(evnet) {
|
||||
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
||||
// console.log("### enter ###");
|
||||
var inputContent = this.inputTextContent.canvasInput.value();
|
||||
var typingContent = this.typingRandomContents[this.typingIndex];
|
||||
let inputContent = this.inputTextContent.canvasInput.value();
|
||||
let typingContent = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
if(inputContent == typingContent) {
|
||||
this.calculateTypingRecord(typingContent);
|
||||
@@ -313,8 +313,8 @@ class TypingTest {
|
||||
}
|
||||
|
||||
showTypingContentHighlight() {
|
||||
var typingContent = this.typingRandomContents[this.typingIndex];
|
||||
var inputContent = this.inputTextContent.canvasInput.value();
|
||||
let typingContent = this.typingRandomContents[this.typingIndex];
|
||||
let inputContent = this.inputTextContent.canvasInput.value();
|
||||
|
||||
this.textTypingContent.clearColors();
|
||||
this.textTypingContent.addColor(TypingTest.COLOR_CONTENT_RIGHT, 0);
|
||||
@@ -322,8 +322,8 @@ class TypingTest {
|
||||
if(typingContent == null)
|
||||
return;
|
||||
|
||||
var typingContentLength = typingContent.length;
|
||||
for(var i = 0; i < typingContentLength; i++) {
|
||||
let typingContentLength = typingContent.length;
|
||||
for(let i = 0; i < typingContentLength; i++) {
|
||||
// console.log("typingContent.charAt(i) : " + typingContent.charAt(i));
|
||||
// console.log("inputContent.charAt(i) : " + inputContent.charAt(i));
|
||||
|
||||
@@ -341,21 +341,21 @@ class TypingTest {
|
||||
this.timeTypingEnd = game.time.elapsedSince(0);
|
||||
// console.log('this.timeTypingEnd : ' + this.timeTypingEnd);
|
||||
|
||||
var elapsedTimeMS = this.timeTypingEnd - this.timeTypingStart;
|
||||
let elapsedTimeMS = this.timeTypingEnd - this.timeTypingStart;
|
||||
// console.log('elapsedTimeMS : ' + elapsedTimeMS);
|
||||
|
||||
var typingContentLength = StringUtil.getUnicodeAlphabetCount(typingContent);
|
||||
let typingContentLength = StringUtil.getUnicodeAlphabetCount(typingContent);
|
||||
// console.log('typingContentLength : ' + typingContentLength);
|
||||
var typingContentPlusEnterCount = typingContentLength + TypingTest.TYPING_COUNT_PLUS_ENTER;
|
||||
let typingContentPlusEnterCount = typingContentLength + TypingTest.TYPING_COUNT_PLUS_ENTER;
|
||||
|
||||
var typingRecord = (typingContentPlusEnterCount + TypingTest.TYPING_COUNT_PLUS_ENTER) * 60000 / elapsedTimeMS;
|
||||
let typingRecord = (typingContentPlusEnterCount + TypingTest.TYPING_COUNT_PLUS_ENTER) * 60000 / elapsedTimeMS;
|
||||
|
||||
this.typingElapsedTime[this.typingIndex] = elapsedTimeMS;
|
||||
this.typingLetterCountTotal += typingContentPlusEnterCount;
|
||||
this.typingRecordForLines[this.typingIndex] = typingRecord;
|
||||
// console.log(this.typingRecordForLines[this.typingIndex]);
|
||||
|
||||
var typingElapsedTimeTotal = 0;
|
||||
let typingElapsedTimeTotal = 0;
|
||||
for(let i = 0; i <= this.typingIndex; i++) {
|
||||
// console.log('i : ' + i + ' - time : ' + this.typingElapsedTime[i]);
|
||||
typingElapsedTimeTotal += this.typingElapsedTime[i];
|
||||
@@ -386,7 +386,7 @@ class TypingTest {
|
||||
|
||||
setTimeTypingStart() {
|
||||
this.timeTypingStart = game.time.elapsedSince(0);
|
||||
var timeGap = this.timeTypingStart - this.timeTypingEnd;
|
||||
let timeGap = this.timeTypingStart - this.timeTypingEnd;
|
||||
|
||||
if(timeGap < 50)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user