Fix: spaceship image, start random flyingsaucer

This commit is contained in:
2019-01-10 13:07:09 +09:00
parent b8faa417d8
commit 33c70e6d5c
10 changed files with 155 additions and 84 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 528 B

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 B

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 585 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.
+36 -19
View File
@@ -1,15 +1,14 @@
CenterMessageText.prototype = Object.create(Phaser.Text.prototype);
CenterMessageText.constructor = CenterMessageText;
function CenterMessageText(contentText) {
function CenterMessageText() {
Phaser.Text.call(
this, game,
game.world.width / 2,
game.world.height / 2 - CenterMessageText.MOVE_AMOUNT_PX,
contentText,
"",
CenterMessageText.DEFAULT_TEXT_FONT
);
// super(game, 600, 300, "게임 오버", CenterMessageText.DEFAULT_TEXT_FONT);
this.anchor.set(0.5);
this.inputEnabled = false;
@@ -18,37 +17,55 @@ function CenterMessageText(contentText) {
// grd.addColorStop(0, CenterMessageText.COLOR_GRADATION_START); //'#FFD68E');
// grd.addColorStop(1, CenterMessageText.COLOR_GRADATION_END); //'#B34C00');
// this.fill = grd;
this.fill = CenterMessageText.COLOR_TEXT;
// this.fill = CenterMessageText.COLOR_TEXT;
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
this.stroke = CenterMessageText.COLOR_STROKE;
this.strokeThickness = 9;
this.tweenAlpha = game.add.tween(this);
this.tweenAlpha.to( { alpha: 0 }, CenterMessageText.TWEEN_ALPHA_TIME, Phaser.Easing.Elastic.In, false);
// this.tweenAlpha.onComplete.addOnce(this.hide, this);
this.alpha = 1;
var tweenAlpha = game.add.tween(this);
tweenAlpha.to( { alpha: 0 }, CenterMessageText.TWEEN_ALPHA_TIME, Phaser.Easing.Elastic.In, true);
tweenAlpha.onComplete.addOnce(this.destroy, this);
// var tweenScale = game.add.tween(this.scale);
// tweenScale.to( { x: 0.8, y: 0.8 }, CenterMessageText.TWEEN_SCALE_TIME, Phaser.Easing.Bounce.Out, true);
// tweenScale.onComplete.addOnce(this.destroy, this);
this.timerEventTween = null;
this.alpha = 0;
game.add.existing(this);
};
CenterMessageText.prototype.showText = function(wordLevel, wordLevelText) {
if(this.timerEventTween)
game.time.events.remove(this.timerEventTween);
if(this.tweenAlpha != null)
this.tweenAlpha.stop();
this.text = "[ " + wordLevelText + " ] 단계 활성화";
this.fill = GameLevelManager.CENTER_MESSAGE_TEXT_COLOR_LIST[wordLevel];
this.stroke = GameLevelManager.CENTER_MESSAGE_STROKE_COLOR_LIST[wordLevel];
// console.log(this.fill);
// console.log(this.stroke);
this.alpha = 1;
this.tweenAlpha.start();
this.timerEventTween = game.time.events.add(CenterMessageText.TWEEN_ALPHA_TIME, this.hide, this);
}
CenterMessageText.prototype.hide = function() {
this.alpha = 0;
}
CenterMessageText.DEFAULT_TEXT_FONT = {
font: "bold 40px Arial", // "bold 100px Arial",
font: "bold 40px Arial",
boundsAlignH: "center", // left, center. right
boundsAlignV: "middle", // top, middle, bottom
fill: CenterMessageText.COLOR_TEXT // "#fff"
fill: "#ffffff"
};
CenterMessageText.MOVE_AMOUNT_PX = 100;
CenterMessageText.TWEEN_ALPHA_TIME = 1500;
CenterMessageText.TWEEN_SCALE_TIME = 1500;
CenterMessageText.COLOR_TEXT = "#ffcc00"; // "#cc9900";
CenterMessageText.COLOR_GRADATION_START = "#B34C00"; // "#333333"; //"#666666";
CenterMessageText.COLOR_GRADATION_END = "#333333"; // "#B34C00";
CenterMessageText.COLOR_STROKE = "#663300"; //"#FFDD88"; //"#FFD68E";
CenterMessageText.COLOR_TEXT = "#ffcc00";
CenterMessageText.COLOR_GRADATION_START = "#B34C00";
CenterMessageText.COLOR_GRADATION_END = "#333333";
CenterMessageText.COLOR_STROKE = "#663300";
@@ -57,6 +57,17 @@ ExtractWordManager.prototype.initVariables = function() {
}
}
ExtractWordManager.prototype.getWordLevelCount = function() {
// console.log("this.easyWordList.length : " + this.easyWordList.length);
// console.log("this.hardWordList.length : " + this.hardWordList.length);
var wordLevelCount = this.easyWordList.length;
if(wordLevelCount < this.hardWordList.length)
wordLevelCount = this.hardWordList.length;
return wordLevelCount;
}
ExtractWordManager.prototype.pickOutDifficulty = function(wordList, difficultyForLevel) {
var pickOutWordList = [];
@@ -120,6 +131,12 @@ ExtractWordManager.prototype.getWord = function(wordLevel, difficultyForLevel) {
// console.log("wordLevel : " + wordLevel);
// console.log("difficultyForLevel : " + difficultyForLevel);
if(this.easyWordList[wordLevel] == undefined || this.hardWordList[wordLevel] == undefined) {
console.log("====== Error ======");
console.log("wordLevel : " + wordLevel);
console.log("difficultyForLevel : " + difficultyForLevel);
}
var word = "";
if(difficultyForLevel == ExtractWordManager.DIFFICULTY_EASY)
word = this.spliceRandomWord(this.easyWordList[wordLevel]);
@@ -7,7 +7,7 @@ function FlyingSaucer(lineIndex) {
this.initVariables();
Phaser.Sprite.call(this, game, game.world.centerX, game.world.centerY, 'alien_normal');
Phaser.Sprite.call(this, game, game.world.centerX, game.world.centerY, 'ship_cockpit');
game.add.existing(this);
game.physics.arcade.enable(this);
@@ -15,11 +15,11 @@ function FlyingSaucer(lineIndex) {
this.anchor.set(0.5);
this.halfWidth = this.width / 2;
var COCKPIT_OFFSET_Y = -5;
var BODY_OFFSET_Y = 28;
var JET_OFFSET_Y = 52;
var ALIEN_OFFSET_Y = -12;
var BODY_OFFSET_Y = 14;
var JET_OFFSET_Y = 40;
this.cockpit = this.makeCockpit(0, COCKPIT_OFFSET_Y);
this.cockpit = this.makeAlien(0, ALIEN_OFFSET_Y);
this.addChild(this.cockpit);
this.jetLeft = this.makeJet(-50, JET_OFFSET_Y);
@@ -69,19 +69,17 @@ FlyingSaucer.prototype.initVariables = function() {
this.tweenScale = null;
}
FlyingSaucer.prototype.makeCockpit = function(posX, posY) {
var cockpit = game.make.sprite(posX, posY, 'ship_cockpit');
cockpit.anchor.set(0.5);
cockpit.alpha = 0.6;
cockpit.tint = 0xff00ff;
FlyingSaucer.prototype.makeAlien = function(posX, posY) {
var alien = game.make.sprite(posX, posY, 'alien_normal');
alien.anchor.set(0.5);
return cockpit;
return alien;
}
FlyingSaucer.prototype.makeJet = function(posX, posY) {
var jet = game.make.sprite(posX, posY, 'ship_jet');
jet.anchor.set(0.5);
jet.tint = FlyingSaucer.JET_COLOR_HIGH;
// jet.tint = FlyingSaucer.JET_COLOR_HIGH;
return jet;
}
@@ -142,7 +140,7 @@ FlyingSaucer.prototype.changeJetColor = function(color) {
}
FlyingSaucer.prototype.changeCockpitColor = function(color) {
this.cockpit.tint = FlyingSaucer.COKCPIT_COLOR[this.wordLevel];
this.tint = GameLevelManager.COCKPIT_COLOR_LIST[this.wordLevel];
}
@@ -218,7 +216,7 @@ FlyingSaucer.prototype.startAttack = function() {
this.word = this.extractWordManager.getWord(this.wordLevel, this.difficultyForLevel);
// console.log("this.word : " + this.word);
this.setWord(this.word);
this.standardScore = this.gameLevelManager.getStandardScore(this.wordLevel, this.speed);
this.standardScore = this.gameLevelManager.getStandardScore(this.wordLevel, this.difficultyForLevel, this.speed);
// console.log(this.standardScore);
this.moveInitialPos();
@@ -365,10 +363,10 @@ FlyingSaucer.SPEED_DOWN_AMOUNT = FlyingSaucer.SPEED_UP_AMOUNT / 2; // dot per s
FlyingSaucer.START_POS_Y = 100; // px
FlyingSaucer.CRASH_POS_Y = GAME_SCREEN_SIZE.y - 200; // px
FlyingSaucer.WORD_TEXT_OFFSET_Y = 30; // px
FlyingSaucer.WORD_TEXT_OFFSET_Y = 18; // px
FlyingSaucer.TEXT_COLOR_NORMAL = "#000000";
FlyingSaucer.TEXT_COLOR_CORRECT = "#ffff4d";
FlyingSaucer.TEXT_COLOR_NORMAL = "#ffffff";
FlyingSaucer.TEXT_COLOR_CORRECT = "#ffcc00"; // "#ffff4d";
FlyingSaucer.TEXT_STROKE_COLOR = "#ffffff";
FlyingSaucer.JET_STATUS_HIGH = 0;
@@ -377,10 +375,4 @@ FlyingSaucer.JET_STATUS_LOW = 2;
FlyingSaucer.JET_COLOR_HIGH = 0x00ff00; //0x00ffff;
FlyingSaucer.JET_COLOR_MIDDLE = 0xffff00; //0xffff00;
FlyingSaucer.JET_COLOR_LOW = 0xff0000;
FlyingSaucer.COKCPIT_COLOR = [
// 0xff0000, 0xff6600, 0xffff00, 0x00ffff, 0x00ffff, 0x6666ff, 0xff00ff
// 0x00ffff, 0x55aacc, 0x0000ff, 0x8800cc, 0xff00ff, 0x6666ff, 0xff00ff
0xffff33, 0x00ff00, 0x00ccff, 0x3366ff, 0x9933ff, 0xff00ff, 0xff6600
]
FlyingSaucer.JET_COLOR_LOW = 0xff0000;
+26 -14
View File
@@ -55,10 +55,10 @@ var WordFlyingSaucer = {
this.flyingsaucers[i].setHeartManager(this.heartManager);
this.flyingsaucers[i].setExtractWordManager(this.extractWordManager);
this.flyingsaucers[i].setGameLevelManager(this.gameLevelManager);
this.flyingsaucers[i].startAttack();
// this.flyingsaucers[i].startAttack();
}
this.centerMessageText = new CenterMessageText();
// top ui
var screenTopUI = new ScreenTopUI();
@@ -93,8 +93,7 @@ var WordFlyingSaucer = {
this.screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
// this.startGame();
this.showLevelUpText();
this.startGame();
},
@@ -107,6 +106,7 @@ var WordFlyingSaucer = {
initVariables: function() {
this.extractWordManager = new ExtractWordManager();
this.gameLevelManager = new GameLevelManager(this);
this.gameLevelManager.setExtractWordManager(this.extractWordManager);
this.speedLevel = 0;
@@ -144,7 +144,6 @@ var WordFlyingSaucer = {
bmd.rect(0, y, GAME_SCREEN_SIZE.x, y + GRADIATION_HEIGHT, Phaser.Color.getWebRGB(c));
y += GRADIATION_HEIGHT;
}
console.log("final y : " + y);
var stars = game.add.group();
for (var i = 0; i < 128; i++) {
@@ -153,17 +152,33 @@ var WordFlyingSaucer = {
}
var GROUND_OFFSET_Y = 600;
// this.tileSprite = game.add.tileSprite(50, GROUND_OFFSET_Y, GAME_SCREEN_SIZE.x + 50, GROUND_OFFSET_Y + 150, "tile_choco");
// this.tileSprite = game.add.tileSprite(300, 300, 100, 100, "tile_choco");
this.tileSprite = game.add.tileSprite(
GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y,
GAME_SCREEN_SIZE.x, 200,
GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y - 50,
GAME_SCREEN_SIZE.x, 100,
"tile_choco");
this.tileSprite.anchor.set(0.5);
this.tileSprite.tileScale.set(2);
},
startGame: function() {
this.showLevelUpText(this.gameLevelManager.getWordLevel()); // initial wordLevel = 0;
var startIndexList = [];
for(var i = 0; i < WordFlyingSaucer.MAX_FLYINGSAUCER_COUNT; i++)
startIndexList.push(i);
this.randomStartIndex = 0;
this.randomStartIndexList = Phaser.ArrayUtils.shuffle(startIndexList);
for(var i = 0; i < this.randomStartIndexList.length; i++) {
var randomDelayTime = Phaser.Timer.SECOND * 2 * i + Math.random() * Phaser.Timer.SECOND;
game.time.events.add(randomDelayTime, this.waitAndStartAttack, this);
}
},
waitAndStartAttack: function() {
var index = this.randomStartIndexList[this.randomStartIndex];
this.flyingsaucers[index].startAttack();
this.randomStartIndex++;
},
timeOver: function() {
@@ -224,11 +239,8 @@ var WordFlyingSaucer = {
}
},
showLevelUpText: function() {
if(this.centerMessageText)
// this.centerMessageText.text = "";
this.centerMessageText.destroy();
this.centerMessageText = new CenterMessageText("[ " + this.gameLevelManager.getWordLevelText() + " ] 단계 활성화");
showLevelUpText: function(wordLevel) {
this.centerMessageText.showText(wordLevel, this.gameLevelManager.getWordLevelText(wordLevel));
},
}
@@ -1,23 +1,31 @@
function GameLevelManager(mainGame) {
this.mainGame = mainGame;
this.extractWordManager = null;
this.wordLevel = 0;
this.clearedWordCountForLevel = [0, 0, 0, 0, 0, 0];
}
GameLevelManager.prototype.setExtractWordManager = function(extractWordManager) {
this.extractWordManager = extractWordManager;
this.difficultyForLevelList = [];
for(var i = 0; i < GameLevelManager.MAX_WORD_LEVEL; i++)
var count = this.extractWordManager.getWordLevelCount();
for(var i = 0; i < count; i++)
this.difficultyForLevelList[i] = ExtractWordManager.DIFFICULTY_EASY;
}
GameLevelManager.prototype.getWordLevel = function() {
// return this.wordLevel;
var randomLevel = Math.floor(Math.random() * (this.wordLevel + 1));
return randomLevel;
}
GameLevelManager.prototype.getWordLevelText = function() {
GameLevelManager.prototype.getWordLevelText = function(wordLevel) {
var wordLevelText = "";
switch(this.wordLevel) {
switch(wordLevel) {
case 0:
if(isKoreanTypingApp()) wordLevelText = "기본자리";
else wordLevelText = "Basic";
@@ -65,14 +73,15 @@ GameLevelManager.prototype.getDifficultyForLevel = function(wordLevel) {
return this.difficultyForLevelList[wordLevel];
}
GameLevelManager.prototype.getStandardScore = function(wordLevel, speed) {
return (wordLevel + 1) * (speed + 1);
GameLevelManager.prototype.getStandardScore = function(wordLevel, difficulty, speed) {
return (wordLevel + 1) * (1 + difficulty) * (speed + 1);
}
GameLevelManager.prototype.clearWord = function(wordLevel, landingRatio) {
// console.log("====");
// for(var i = 0; i < GameLevelManager.MAX_WORD_LEVEL; i++) {
// var count = this.extractWordManager.getWordLevelCount();
// for(var i = 0; i < count; i++) {
// console.log("difficultyForLevelList[" + i + "] : " + this.difficultyForLevelList[i]);
// }
@@ -81,29 +90,20 @@ GameLevelManager.prototype.clearWord = function(wordLevel, landingRatio) {
this.increaseClearedWordCountForLevel(wordLevel);
if(this.wordLevel == GameLevelManager.MAX_WORD_LEVEL) {
// console.log("*** no more higher word level");
return;
}
if(wordLevel < this.wordLevel) {
// console.log("*** already goNextLevel");
return;
}
if(landingRatio < GameLevelManager.LEVEL_UP_LANDING_RATIO) {
// console.log("*** not enough ratio");
return;
}
this.goNextWordLevel();
this.goNextWordLevel(wordLevel);
}
GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel) {
this.clearedWordCountForLevel[wordLevel] += 1;
// console.log("====");
// for(var i = 0; i < GameLevelManager.MAX_WORD_LEVEL; i++) {
// var count = this.extractWordManager.getWordLevelCount();
// for(var i = 0; i < count; i++) {
// console.log("clearedWordCountForLevel[" + i + "] : " + this.clearedWordCountForLevel[i]);
// }
@@ -124,20 +124,53 @@ GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel
}
}
GameLevelManager.prototype.goNextWordLevel = function() {
this.wordLevel++;
GameLevelManager.prototype.goNextWordLevel = function(wordLevel) {
if(wordLevel < this.wordLevel) {
// console.log("*** already goNextLevel");
return;
}
this.mainGame.showLevelUpText();
// console.log("goNextWordLevel to " + this.wordLevel);
if(this.wordLevel < this.extractWordManager.getWordLevelCount() - 1) {
this.wordLevel++;
this.mainGame.showLevelUpText(this.wordLevel);
}
}
GameLevelManager.LEVEL_UP_LANDING_RATIO = 0.7;
GameLevelManager.WARNING_LANDING_RATIO = 0.3;
GameLevelManager.MAX_WORD_LEVEL = 6;
GameLevelManager.CLEARED_WORD_COUNT_FOR_NEXT_LEVEL = [15, 12, 10, 9, 8, 7];
// GameLevelManager.KOREAN_WORD_LENGTH = [2, 3];
// GameLevelManager.ENGLISH_WORD_LENGTH = [3, 6];;
GameLevelManager.COCKPIT_COLOR_LIST = [
0xff66ff,
0x9966ff,
0x3399ff,
0x00ffff,
0x66ff66,
0xffff66,
0xff6633,
0xff6666
]
GameLevelManager.CENTER_MESSAGE_TEXT_COLOR_LIST = [
"#ff66ff",
"#9966ff",
"#3399ff",
"#00ffff",
"#66ff66",
"#ffff66",
"#ff6633",
"#ff6666"
]
GameLevelManager.CENTER_MESSAGE_STROKE_COLOR_LIST = [
"#662266",
"#332266",
"#113366",
"#006666",
"#226622",
"#666622",
"#662211",
"#662222"
]
+1 -1
View File
@@ -23,7 +23,7 @@
<!-- End Google Tag Manager -->
<title>격추! 비행접시 | 초코마에</title>
<meta name="description" CONTENT="격추! 비행접시 - 한글/영어 타자 앱 | 초코마에 ‧ Shoot down! flyingsaucer - Korean/English typing app | ChocoMae">
<meta name="description" CONTENT="단어 비행접시 - 한글/영어 타자 앱 | 초코마에 ‧ Word flyingsaucer - Korean/English typing app | ChocoMae">
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />