Fix: reduce score not reset in typing practice
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
var LANGUAGE_KOREAN = "korean";
|
||||
var LANGUAGE_ENGLISH = "english";
|
||||
var LANGUAGE_ENGLISH = "english";
|
||||
|
||||
var MODE_RELEASE = "release";
|
||||
var MODE_RELEASE = "release";
|
||||
var MODE_DEBUG = "debug";
|
||||
var runMode = MODE_DEBUG;
|
||||
|
||||
@@ -163,4 +163,4 @@ function getGameAppName() {
|
||||
}
|
||||
|
||||
|
||||
let textStyleBasic = { font: "bold 32px Arial", fill: "#fff", align: "center", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
var textStyleBasic = { font: "bold 32px Arial", fill: "#fff", align: "center", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
|
||||
@@ -5,7 +5,6 @@ function Animal(type, index, x, y) {
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
|
||||
// this.sprite = game.add.sprite(this.posX, this.posY); //, "snail_run1"); // this.spriteFrameNames.run1);
|
||||
this.sprite = game.add.sprite(this.posX, this.posY, "animals");
|
||||
this.sprite.anchor.set(0.5);
|
||||
this.sprite.animations.add("stand", [index * 2]);
|
||||
@@ -20,10 +19,6 @@ Animal.prototype.setScale = function(value) {
|
||||
this.sprite.scale.set(value);
|
||||
}
|
||||
|
||||
// Animal.prototype.setIconSprite = function(species) {
|
||||
// this.setSpecies(species);
|
||||
// }
|
||||
|
||||
Animal.prototype.setSpecies = function(species) {
|
||||
console.log(species);
|
||||
this.species = species;
|
||||
@@ -51,10 +46,6 @@ Animal.prototype.tweenAnimation = function(animationType) {
|
||||
}
|
||||
}
|
||||
|
||||
// Animal.prototype.setupAnimation = function() {
|
||||
// this.stopAnimation();
|
||||
// }
|
||||
|
||||
Animal.prototype.startAnimation = function(species) {
|
||||
this.sprite.animations.play("run", this.species.fps, true);
|
||||
}
|
||||
@@ -86,8 +77,6 @@ Animal.typingCount = function(speciesData, gameType) {
|
||||
|
||||
Animal.loadResources = function() {
|
||||
game.load.spritesheet('animals', '../../../resources/image/character/animal/animals.png', 50, 50);
|
||||
|
||||
// game.load.image('snail_shadow', '../../../resources/image/character/animal/snail/shadow.png');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,14 +3,23 @@ ScoreText.constructor = ScoreText;
|
||||
|
||||
function ScoreText(x, y, score) {
|
||||
// super(game, x, y, "+" + NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT);
|
||||
Phaser.Text.call(this, game, x, y, "+" + NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT);
|
||||
var scoreValue = Number(score);
|
||||
if(scoreValue > 0)
|
||||
Phaser.Text.call(this, game, x, y, "+" + NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT);
|
||||
else if(scoreValue < 0)
|
||||
Phaser.Text.call(this, game, x, y, NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT);
|
||||
|
||||
this.anchor.set(0.5);
|
||||
this.inputEnabled = false;
|
||||
|
||||
var grd = this.context.createLinearGradient(0, 0, 0, this.height);
|
||||
grd.addColorStop(0, '#8ED6FF');
|
||||
grd.addColorStop(1, '#004CB3');
|
||||
if(scoreValue < 0) {
|
||||
grd.addColorStop(0, ScoreText.COLOR_MINUS_SCORE_GRADATION_1);
|
||||
grd.addColorStop(1, ScoreText.COLOR_MINUS_SCORE_GRADATION_2);
|
||||
} else {
|
||||
grd.addColorStop(0, ScoreText.COLOR_PLUS_SCORE_GRADATION_1);
|
||||
grd.addColorStop(1, ScoreText.COLOR_PLUS_SCORE_GRADATION_2);
|
||||
}
|
||||
this.fill = grd;
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
this.stroke = '#fff';
|
||||
@@ -40,3 +49,9 @@ ScoreText.DEFAULT_TEXT_FONT = {
|
||||
};
|
||||
|
||||
ScoreText.MOVE_UP_AMOUNT_PX = 50;
|
||||
|
||||
ScoreText.COLOR_PLUS_SCORE_GRADATION_1 = "#8ED6FF";
|
||||
ScoreText.COLOR_PLUS_SCORE_GRADATION_2 = "#004CB3";
|
||||
|
||||
ScoreText.COLOR_MINUS_SCORE_GRADATION_1 = "#FFD68E";
|
||||
ScoreText.COLOR_MINUS_SCORE_GRADATION_2 = "#B34C00";
|
||||
@@ -93,7 +93,7 @@ var Result = {
|
||||
var animalLevelID = 0;
|
||||
if(isTypingPracticeApp())
|
||||
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_PRACTICE);
|
||||
else
|
||||
else // Typing Test App
|
||||
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_TEST);
|
||||
|
||||
var leftAnimal = new Animal(Animal.TYPE_ANIMATION, animalLevelID, game.world.centerX - 200, 150);
|
||||
|
||||
@@ -2,65 +2,69 @@ function TypingContentBG() {
|
||||
}
|
||||
|
||||
TypingContentBG.prototype.makePracticeContentBG = function() {
|
||||
var CONTENT_Y = 140;
|
||||
var contentY = TypingContentBG.POS_Y_CONTENT_BOX_TYPING_PRACTICE;
|
||||
|
||||
var bar = game.add.graphics();
|
||||
if(isKoreanTypingApp()) {
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y, GAME_SCREEN_SIZE.x, 120);
|
||||
bar.drawRect(0, contentY, GAME_SCREEN_SIZE.x, 120);
|
||||
} else {
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y, GAME_SCREEN_SIZE.x, 40);
|
||||
bar.drawRect(0, contentY, GAME_SCREEN_SIZE.x, 40);
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_ALPHABET_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y + 40, GAME_SCREEN_SIZE.x, 50);
|
||||
bar.drawRect(0, contentY + 40, GAME_SCREEN_SIZE.x, 50);
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y + 90, GAME_SCREEN_SIZE.x, 30);
|
||||
bar.drawRect(0, contentY + 90, GAME_SCREEN_SIZE.x, 30);
|
||||
}
|
||||
}
|
||||
|
||||
TypingContentBG.prototype.makeTestContentBG = function() {
|
||||
var CONTENT_Y = 260;
|
||||
var contentY = TypingContentBG.POS_Y_CONTENT_BOX_TYPING_TEST;
|
||||
|
||||
var bar = game.add.graphics();
|
||||
if(isKoreanTypingApp()) {
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y, GAME_SCREEN_SIZE.x, 120);
|
||||
bar.drawRect(0, contentY, GAME_SCREEN_SIZE.x, 120);
|
||||
} else {
|
||||
if(isTypingSentenceApp()) {
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y, GAME_SCREEN_SIZE.x, 46);
|
||||
bar.drawRect(0, contentY, GAME_SCREEN_SIZE.x, 46);
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_ALPHABET_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y + 46, GAME_SCREEN_SIZE.x, 30);
|
||||
bar.drawRect(0, contentY + 46, GAME_SCREEN_SIZE.x, 30);
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y + 76, GAME_SCREEN_SIZE.x, 44);
|
||||
bar.drawRect(0, contentY + 76, GAME_SCREEN_SIZE.x, 44);
|
||||
} else {
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y, GAME_SCREEN_SIZE.x, 40);
|
||||
bar.drawRect(0, contentY, GAME_SCREEN_SIZE.x, 40);
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_ALPHABET_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y + 40, GAME_SCREEN_SIZE.x, 50);
|
||||
bar.drawRect(0, contentY + 40, GAME_SCREEN_SIZE.x, 50);
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y + 90, GAME_SCREEN_SIZE.x, 30);
|
||||
bar.drawRect(0, contentY + 90, GAME_SCREEN_SIZE.x, 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TypingContentBG.prototype.makeWhacAMoleContentBG = function() {
|
||||
var CONTENT_Y = 200;
|
||||
var contentY = TypingContentBG.POS_Y_CONTENT_BOX_TYPING_WHACAMOLE;
|
||||
|
||||
var bar = game.add.graphics();
|
||||
if(isKoreanTypingApp()) {
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y, GAME_SCREEN_SIZE.x, 120);
|
||||
bar.drawRect(0, contentY, GAME_SCREEN_SIZE.x, 120);
|
||||
} else {
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y, GAME_SCREEN_SIZE.x, 40);
|
||||
bar.drawRect(0, contentY, GAME_SCREEN_SIZE.x, 40);
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_ALPHABET_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y + 40, GAME_SCREEN_SIZE.x, 50);
|
||||
bar.drawRect(0, contentY + 40, GAME_SCREEN_SIZE.x, 50);
|
||||
bar.beginFill(TypingContentBG.COLOR_CONTENT_BG, 1);
|
||||
bar.drawRect(0, CONTENT_Y + 90, GAME_SCREEN_SIZE.x, 30);
|
||||
bar.drawRect(0, contentY + 90, GAME_SCREEN_SIZE.x, 30);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TypingContentBG.COLOR_CONTENT_BG = 0x444444;
|
||||
TypingContentBG.COLOR_CONTENT_ALPHABET_BG = 0x3d3d3d;
|
||||
|
||||
TypingContentBG.POS_Y_CONTENT_BOX_TYPING_PRACTICE = 140;
|
||||
TypingContentBG.POS_Y_CONTENT_BOX_TYPING_TEST = 260;
|
||||
TypingContentBG.POS_Y_CONTENT_BOX_TYPING_WHACAMOLE = 200;
|
||||
|
||||
@@ -157,7 +157,7 @@ var TypingPractice = {
|
||||
},
|
||||
|
||||
goResult: function() {
|
||||
sessionStorageManager.setRecord(this.typingScore.score());
|
||||
sessionStorageManager.setRecord(this.typingScore.getScore());
|
||||
|
||||
location.href = '../../web/client/result.html';
|
||||
},
|
||||
@@ -365,8 +365,15 @@ var TypingPractice = {
|
||||
var typingContent = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
if(this.isKeyPressed(inputContent, typingContent)) {
|
||||
this.typingScore.increase();
|
||||
var animalLevelID = Animal.animalLevelIDByRecord(this.typingScore.score(), Animal.TYPE_PRACTICE);
|
||||
var plusScore = 1;
|
||||
this.typingScore.add(plusScore);
|
||||
var scoreText = new ScoreText(
|
||||
game.world.centerX,
|
||||
TypingContentBG.POS_Y_CONTENT_BOX_TYPING_PRACTICE,
|
||||
plusScore
|
||||
);
|
||||
|
||||
var animalLevelID = Animal.animalLevelIDByRecord(this.typingScore.getScore(), Animal.TYPE_PRACTICE);
|
||||
// console.log(animalLevelID);
|
||||
// console.log(this.playingAnimalIndex);
|
||||
if(animalLevelID > this.playingAnimalIndex) {
|
||||
@@ -382,7 +389,17 @@ var TypingPractice = {
|
||||
} else {
|
||||
if(this.playingAnimalIndex > 0)
|
||||
this.playingAnimalIndex--;
|
||||
var prevScore = this.typingScore.getScore();
|
||||
this.typingScore.set(Animal.getAnimalPracticeTypingCount(this.playingAnimalIndex));
|
||||
var presentScore = this.typingScore.getScore();
|
||||
|
||||
if(presentScore - prevScore < 0) {
|
||||
var scoreText = new ScoreText(
|
||||
game.world.centerX,
|
||||
TypingContentBG.POS_Y_CONTENT_BOX_TYPING_PRACTICE,
|
||||
presentScore - prevScore
|
||||
);
|
||||
}
|
||||
|
||||
this.animalList.activate(this.playingAnimalIndex);
|
||||
this.animalList.tweenAnimation(Animal.ANIMATION_TYPE_DAMAGE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function TypingScore() {
|
||||
this.typingCount = 0;
|
||||
this.score = 0;
|
||||
|
||||
var fontStyle = TypingScore.DEFAULT_TEXT_FONT;
|
||||
|
||||
@@ -24,36 +24,36 @@ function TypingScore() {
|
||||
// this.scoreText.strokeThickness = 3;
|
||||
};
|
||||
|
||||
TypingScore.prototype.score = function() {
|
||||
return this.typingCount;
|
||||
TypingScore.prototype.getScore = function() {
|
||||
return this.score;
|
||||
}
|
||||
|
||||
TypingScore.prototype.increase = function() {
|
||||
this.typingCount++;
|
||||
this.print(this.typingCount);
|
||||
TypingScore.prototype.add = function(value) {
|
||||
this.score += value;
|
||||
this.print(this.score);
|
||||
}
|
||||
|
||||
TypingScore.prototype.reset = function() {
|
||||
this.typingCount = 0;
|
||||
this.print(this.typingCount);
|
||||
this.score = 0;
|
||||
this.print(this.score);
|
||||
}
|
||||
|
||||
TypingScore.prototype.set = function(score) {
|
||||
this.typingCount = score;
|
||||
this.print(this.typingCount);
|
||||
this.score = score;
|
||||
this.print(this.score);
|
||||
}
|
||||
|
||||
TypingScore.prototype.print = function(typingCount) {
|
||||
this.scoreText.text = typingCount;
|
||||
TypingScore.prototype.print = function(score) {
|
||||
this.scoreText.text = score;
|
||||
}
|
||||
|
||||
|
||||
TypingScore.SCORE_POS_Y = 35;
|
||||
|
||||
TypingScore.DEFAULT_TEXT_FONT = {
|
||||
font: "38px Arial",
|
||||
align: "center",
|
||||
boundsAlignH: "center", // left, center. right
|
||||
boundsAlignV: "middle", // top, middle, bottom
|
||||
fill: "#fff"
|
||||
font: "38px Arial",
|
||||
align: "center",
|
||||
boundsAlignH: "center", // left, center. right
|
||||
boundsAlignV: "middle", // top, middle, bottom
|
||||
fill: "#fff"
|
||||
};
|
||||
@@ -35,7 +35,6 @@ var englishSentenceList = [
|
||||
"Nobody's perfect.",
|
||||
"Negligence is a crime.",
|
||||
"Nothing is impossible to a willing heart.",
|
||||
"Never put off till tomorrow what you can do today.",
|
||||
"Never shoot, never hit.",
|
||||
"Never judge by appearance.",
|
||||
"Of a compliment only a third is meant.",
|
||||
|
||||
@@ -16,7 +16,6 @@ var koreanSentenceList = [
|
||||
"구르는 돌에는 이끼가 끼지 않는다.",
|
||||
"구슬이 서 말이라도 꿰어야 보배",
|
||||
"굴러 온 돌이 박힌 돌 뺀다.",
|
||||
"길이 아니면 가지 말고 말이 아니면 듣지 말라.",
|
||||
"까마귀 날자 배 떨어진다.",
|
||||
"낮 말은 새가 듣고 밤 말은 쥐가 듣는다.",
|
||||
"늦게 배운 도둑질이 날 새는 줄 모른다.",
|
||||
@@ -27,7 +26,6 @@ var koreanSentenceList = [
|
||||
"도둑을 맞으려면 개도 안 짖는다.",
|
||||
"도둑이 제 발 저린다.",
|
||||
"돌다리도 두들겨 보고 건너라.",
|
||||
"떡 줄 사람은 생각도 않는데 김칫국부터 마신다.",
|
||||
"똥 묻은 개가 겨 묻은 개 나무란다.",
|
||||
"똥이 무서워서 피하나 더러워서 피하지.",
|
||||
"뛰는 놈 위에 나는 놈 있다.",
|
||||
@@ -35,7 +33,7 @@ var koreanSentenceList = [
|
||||
"못된 송아지 엉덩이에 뿔난다.",
|
||||
"못 먹는 감 찔러나 본다.",
|
||||
"미꾸라지 한 마리가 온 웅덩이를 흐린다.",
|
||||
"믿는 도끼에 발등 찍히다.",
|
||||
"믿는 도끼에 발등 찍힌다.",
|
||||
"밑 빠진 독에 물 붓기.",
|
||||
"바늘 도둑이 소 도둑 된다.",
|
||||
"방귀 뀐 놈이 성낸다.",
|
||||
@@ -44,7 +42,7 @@ var koreanSentenceList = [
|
||||
"번데기 앞에서 주름잡기",
|
||||
"부뚜막의 소금도 집어 넣어야 짜다.",
|
||||
"비온 뒤 땅이 굳는다.",
|
||||
"빈 수레가 더 요란하다.",
|
||||
"빈 수레가 요란하다.",
|
||||
"빈대 잡다 초가삼간 태운다.",
|
||||
"사공이 많으면 배가 산으로 간다.",
|
||||
"서당개 삼년이면 풍월을 읊는다.",
|
||||
@@ -59,7 +57,6 @@ var koreanSentenceList = [
|
||||
"얌전한 고양이 부뚜막에 먼저 오른다.",
|
||||
"안 되는 놈은 뒤로 자빠져도 코가 깨진다.",
|
||||
"어물전 망신은 꼴뚜기가 시킨다.",
|
||||
"열길 물 속은 알아도 한길 사람 속은 모른다.",
|
||||
"열 번 찍어 안 넘어가는 나무 없다.",
|
||||
"오르지 못할 나무는 쳐다보지도 마라.",
|
||||
"오얏나무 아래에서 갓을 고쳐 쓰지 마라.",
|
||||
@@ -78,10 +75,9 @@ var koreanSentenceList = [
|
||||
"털어서 먼지 안 나는 사람 없다.",
|
||||
"팔은 안으로 굽는다.",
|
||||
"피는 물보다 진하다.",
|
||||
"하늘이 무너저도 솟아날 구멍은 있다.",
|
||||
"하늘이 무너져도 솟아날 구멍은 있다.",
|
||||
"하룻강아지 범 무서운줄 모른다.",
|
||||
"호랑이도 제 말 하면 온다.",
|
||||
"호랑이에게 물려가도 정신만 차리면 살 수 있다.",
|
||||
"호랑이를 잡으려면 호랑이굴로 가야 한다.",
|
||||
"호미로 막을걸 가래로 막는다.",
|
||||
"호박에 줄 긋는다고 수박되나.",
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<script src="../../game/lib/animal.js"></script>
|
||||
<script src="../../game/lib/animal_list.js"></script>
|
||||
<script src="../../game/lib/stage_timer.js"></script>
|
||||
<script src="../../game/lib/score_text.js"></script>
|
||||
|
||||
<!-- Test typing : source files -->
|
||||
<script src="../../game/typing/alphabet_list/korean_basic.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user