diff --git a/resources/image/background/tile_choco.afdesign b/resources/image/background/tile_choco.afdesign new file mode 100644 index 0000000..d2e227d Binary files /dev/null and b/resources/image/background/tile_choco.afdesign differ diff --git a/resources/image/background/tile_choco.png b/resources/image/background/tile_choco.png new file mode 100644 index 0000000..156649e Binary files /dev/null and b/resources/image/background/tile_choco.png differ diff --git a/src/game/lib/text/center_message_text.js b/src/game/lib/text/center_message_text.js new file mode 100644 index 0000000..7da992d --- /dev/null +++ b/src/game/lib/text/center_message_text.js @@ -0,0 +1,47 @@ +CenterMessageText.prototype = Object.create(Phaser.Text.prototype); +CenterMessageText.constructor = CenterMessageText; + +function CenterMessageText(contentText) { + 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; + + var grd = this.context.createLinearGradient(0, 0, 0, this.height); + grd.addColorStop(0, "#FFFFFF"); // '#FFD68E'); + grd.addColorStop(1, "#FFD68E"); // '#B34C00'); + this.fill = grd; + // this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); + this.stroke = '#000'; + this.strokeThickness = 10; + + + this.alpha = 0; + var tweenAlpha = game.add.tween(this); + tweenAlpha.to( { alpha: 1 }, CenterMessageText.TWEEN_ALPHA_TIME, Phaser.Easing.Linear.None, true); + + 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); + + game.add.existing(this); +}; + + +CenterMessageText.DEFAULT_TEXT_FONT = { + font: "bold 100px Arial", + boundsAlignH: "center", // left, center. right + boundsAlignV: "middle", // top, middle, bottom + fill: "#fff" +}; + +CenterMessageText.MOVE_AMOUNT_PX = 200; +CenterMessageText.TWEEN_ALPHA_TIME = 1000; +CenterMessageText.TWEEN_SCALE_TIME = 1500; \ No newline at end of file diff --git a/src/game/typing/word_flyingsaucer/flyingsaucer.js b/src/game/typing/word_flyingsaucer/flyingsaucer.js index 987a10c..5185e63 100644 --- a/src/game/typing/word_flyingsaucer/flyingsaucer.js +++ b/src/game/typing/word_flyingsaucer/flyingsaucer.js @@ -37,16 +37,22 @@ function FlyingSaucer(lineIndex) { this.explodeEmitter = this.makeExplodeEmitter(); - var style = { font: "20px Arial", fill: FlyingSaucer.TEXT_COLOR_NORMAL}; + var style = { font: "24px Arial", fill: FlyingSaucer.TEXT_COLOR_NORMAL}; this.wordText = game.add.text(0, 0, "text", style); + // this.wordText.fontWeight = "bold"; + // this.wordText.stroke = FlyingSaucer.TEXT_STROKE_COLOR; + // this.wordText.strokeThickness = 3; this.wordText.anchor.set(0.5); - this.setActive(true); + this.setActive(false); + this.setVisible(false); } FlyingSaucer.prototype.initVariables = function() { this.isActivated = false; + this.isGameOver = false; + this.wordLevel = 0; this.difficultyForLevel = 0; this.standardScore = 0; @@ -58,7 +64,9 @@ FlyingSaucer.prototype.initVariables = function() { this.extractWordManager = null; this.gameLevelManager = null; - this.timerEvent = null; + this.timerEventExplode = null; + + this.tweenScale = null; } FlyingSaucer.prototype.makeCockpit = function(posX, posY) { @@ -98,6 +106,9 @@ FlyingSaucer.prototype.makeExplodeEmitter = function() { FlyingSaucer.prototype.update = function() { + if(this.isGameOver) + return; + if(this.isActivated) { var deltaTime = game.time.elapsed / 1000; this.y += this.speed * deltaTime; @@ -165,8 +176,12 @@ FlyingSaucer.prototype.stop = function() { FlyingSaucer.prototype.setActive = function(isActivated) { this.isActivated = isActivated; +} - if(this.isActivated) +FlyingSaucer.prototype.setVisible = function(isVisible) { + this.isVisible = isVisible; + + if(this.isVisible) this.alpha = 1; else this.alpha = 0; @@ -175,6 +190,9 @@ FlyingSaucer.prototype.setActive = function(isActivated) { FlyingSaucer.prototype.moveInitialPos = function() { this.x = 100 + this.lineIndex * 200; this.y = FlyingSaucer.START_POS_Y; + + this.scale.set(1); + this.speed += FlyingSaucer.SPEED_UP_AMOUNT; this.changeCockpitColor(); @@ -189,6 +207,9 @@ FlyingSaucer.prototype.moveInitialPos = function() { FlyingSaucer.prototype.startAttack = function() { + if(this.isGameOver) + return; + this.wordLevel = this.gameLevelManager.getWordLevel(); this.difficultyForLevel = this.gameLevelManager.getDifficultyForLevel(this.wordLevel); // console.log("===="); @@ -202,6 +223,7 @@ FlyingSaucer.prototype.startAttack = function() { this.moveInitialPos(); this.setActive(true); + this.setVisible(true); } FlyingSaucer.prototype.checkInputText = function(inputText) { @@ -252,8 +274,9 @@ FlyingSaucer.prototype.checkWord = function(inputText) { if(this.word == inputText) { this.gameLevelManager.clearWord(this.wordLevel, this.getLandingRatio()); this.extractWordManager.removeWord(this.wordLevel, this.word); - this.setWord(""); this.setActive(false); + this.setVisible(false); + this.setWord(""); this.explode(); this.plusScore(); @@ -267,7 +290,7 @@ FlyingSaucer.prototype.explode = function(inputText) { this.explodeEmitter.start(true, 1000, null, 100); var randomDelayTime = Phaser.Timer.SECOND / 2 + Math.random() * Phaser.Timer.SECOND * 3; - this.timerEvent = game.time.events.add(randomDelayTime, this.startAttack, this); + this.timerEventExplode = game.time.events.add(randomDelayTime, this.startAttack, this); } FlyingSaucer.prototype.plusScore = function(inputText) { @@ -279,16 +302,42 @@ FlyingSaucer.prototype.plusScore = function(inputText) { } FlyingSaucer.prototype.crash = function() { - this.moveInitialPos(); + this.setActive(false); + this.wordText.text = ""; + + this.tweenScale = game.add.tween(this.scale); + this.tweenScale.to( {x: 10, y: 10}, Phaser.Timer.SECOND / 2, Phaser.Easing.Linear.None); + this.tweenScale.onComplete.addOnce(this.respawn, this); + this.tweenScale.start(); + this.heartManager.breakHearts(1); } -FlyingSaucer.prototype.destroy = function() { - if(this.timerEvent) - game.time.events.remove(this.timerEvent); +FlyingSaucer.prototype.respawn = function() { + this.tweenScale = null; - this.setActive(false); - this.setWord(""); + if(this.isGameOver) { + this.setActive(false); + this.setVisible(false); + this.setWord(""); + + return; + } + + this.startAttack(); +} + +FlyingSaucer.prototype.destroy = function() { + this.isGameOver = true; + + if(this.timerEventExplode) + game.time.events.remove(this.timerEventExplode); + + if(this.tweenScale == null) { + this.setActive(false); + this.setVisible(false); + this.setWord(""); + } } @@ -309,7 +358,7 @@ FlyingSaucer.loadResource = function() { -FlyingSaucer.DEFAULT_SPEED = 10; // dot per sec +FlyingSaucer.DEFAULT_SPEED = 100; // dot per sec FlyingSaucer.SPEED_UP_AMOUNT = 4; // dot per sec FlyingSaucer.SPEED_DOWN_AMOUNT = FlyingSaucer.SPEED_UP_AMOUNT / 2; // dot per sec @@ -320,15 +369,17 @@ FlyingSaucer.WORD_TEXT_OFFSET_Y = 30; // px FlyingSaucer.TEXT_COLOR_NORMAL = "#000000"; FlyingSaucer.TEXT_COLOR_CORRECT = "#ffff4d"; +FlyingSaucer.TEXT_STROKE_COLOR = "#ffffff"; FlyingSaucer.JET_STATUS_HIGH = 0; FlyingSaucer.JET_STATUS_MIDDLE = 1; FlyingSaucer.JET_STATUS_LOW = 2; -FlyingSaucer.JET_COLOR_HIGH = 0x00ffff; -FlyingSaucer.JET_COLOR_MIDDLE = 0xffff00; +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 + // 0xff0000, 0xff6600, 0xffff00, 0x00ffff, 0x00ffff, 0x6666ff, 0xff00ff + 0x00ffff, 0x55aacc, 0x0000ff, 0x8800cc, 0xff00ff, 0x6666ff, 0xff00ff ] \ No newline at end of file diff --git a/src/game/typing/word_flyingsaucer/game.js b/src/game/typing/word_flyingsaucer/game.js index f103a2d..eb8b1cb 100644 --- a/src/game/typing/word_flyingsaucer/game.js +++ b/src/game/typing/word_flyingsaucer/game.js @@ -37,12 +37,7 @@ var WordFlyingSaucer = { // game stage - this.game.stage.backgroundColor = "#000000"; // '#4d4d4d'; - var stars = game.add.group(); - for (var i = 0; i < 128; i++) { - var randomY = game.rnd.integerInRange(60, GAME_SCREEN_SIZE.y - 80); - stars.create(game.world.randomX, randomY, 'star'); - } + this.drawBackground(); this.flyingsaucers = []; for(var i = 0; i < WordFlyingSaucer.MAX_FLYINGSAUCER_COUNT; i++) { @@ -51,7 +46,6 @@ var WordFlyingSaucer = { this.flyingsaucers[i].setHeartManager(this.heartManager); this.flyingsaucers[i].setExtractWordManager(this.extractWordManager); this.flyingsaucers[i].setGameLevelManager(this.gameLevelManager); - this.flyingsaucers[i].setActive(true); this.flyingsaucers[i].startAttack(); } @@ -83,9 +77,6 @@ var WordFlyingSaucer = { } - - - // bottom ui this.screenBottomUI = new ScreenBottomUI(); // screenBottomUI.printBottomUILeftText(""); @@ -105,9 +96,55 @@ var WordFlyingSaucer = { initVariables: function() { this.extractWordManager = new ExtractWordManager(); - this.gameLevelManager = new GameLevelManager(); + this.gameLevelManager = new GameLevelManager(this); this.speedLevel = 0; + + this.tileSprite = null; + }, + + drawBackground: function() { + this.game.stage.backgroundColor = "#000000"; // '#4d4d4d'; + + + var bmd = game.add.bitmapData(GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y); + bmd.addToWorld(); + + var y = 200; + var GRADIATION_HEIGHT = 5; + var GRADIATION_COUNT = 50; + for(var i = 0; i < GRADIATION_COUNT; i++) { + var c = Phaser.Color.interpolateColor( + WordFlyingSaucer.COLOR_ATMOSPHERE_OUTSIDE, + WordFlyingSaucer.COLOR_ATMOSPHERE_INSIDE, + GRADIATION_COUNT, i + ); + bmd.rect(0, y, GAME_SCREEN_SIZE.x, y + GRADIATION_HEIGHT, Phaser.Color.getWebRGB(c)); + y += GRADIATION_HEIGHT; + } + + var GRADIATION_HEIGHT = 10; + var GRADIATION_COUNT = 10; + for(var i = 0; i < GRADIATION_COUNT; i++) { + var c = Phaser.Color.interpolateColor( + WordFlyingSaucer.COLOR_ATMOSPHERE_INSIDE, + WordFlyingSaucer.COLOR_ATMOSPHERE_HORIZON, + GRADIATION_COUNT, i + ); + 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++) { + var randomY = game.rnd.integerInRange(60, GAME_SCREEN_SIZE.y - 80); + stars.create(game.world.randomX, randomY, 'star'); + } + + 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.tileScale.set(2); }, startGame: function() { @@ -171,7 +208,18 @@ var WordFlyingSaucer = { } }, + showLevelUpText: function() { + if(this.centerMessageText) + // this.centerMessageText.text = ""; + this.centerMessageText.destroy(); + this.centerMessageText = new CenterMessageText("단어 난이도 상승!"); + }, + } -WordFlyingSaucer.MAX_FLYINGSAUCER_COUNT = 5; \ No newline at end of file +WordFlyingSaucer.MAX_FLYINGSAUCER_COUNT = 5; + +WordFlyingSaucer.COLOR_ATMOSPHERE_OUTSIDE = 0x000000; +WordFlyingSaucer.COLOR_ATMOSPHERE_INSIDE = 0x444400; +WordFlyingSaucer.COLOR_ATMOSPHERE_HORIZON = 0x440000; \ No newline at end of file diff --git a/src/game/typing/word_flyingsaucer/game_level_manager.js b/src/game/typing/word_flyingsaucer/game_level_manager.js index cac858f..fc9d69b 100644 --- a/src/game/typing/word_flyingsaucer/game_level_manager.js +++ b/src/game/typing/word_flyingsaucer/game_level_manager.js @@ -1,4 +1,6 @@ -function GameLevelManager() { +function GameLevelManager(mainGame) { + this.mainGame = mainGame; + this.wordLevel = 0; this.clearedWordCountForLevel = [0, 0, 0, 0, 0, 0]; @@ -78,12 +80,14 @@ GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel GameLevelManager.prototype.goNextWordLevel = function() { this.wordLevel++; + + this.mainGame.showLevelUpText(); // console.log("goNextWordLevel to " + this.wordLevel); } GameLevelManager.LEVEL_UP_LANDING_RATIO = 0.7; -GameLevelManager.WARNING_LANDING_RATIO = 0.1; +GameLevelManager.WARNING_LANDING_RATIO = 0.3; GameLevelManager.MAX_WORD_LEVEL = 6; diff --git a/src/game/typing/word_flyingsaucer/loading.js b/src/game/typing/word_flyingsaucer/loading.js index 4c47c52..0da2813 100644 --- a/src/game/typing/word_flyingsaucer/loading.js +++ b/src/game/typing/word_flyingsaucer/loading.js @@ -29,6 +29,7 @@ var Loading = { startLoading: function() { game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); + game.load.image('tile_choco', '../../../resources/image/background/tile_choco.png'); game.load.image('star', '../../../resources/image/background/star_7x7.png'); HeartGauge.loadResources(); diff --git a/src/web/client/word_flyingsaucer.html b/src/web/client/word_flyingsaucer.html index 2d2d559..f1f619a 100644 --- a/src/web/client/word_flyingsaucer.html +++ b/src/web/client/word_flyingsaucer.html @@ -48,6 +48,7 @@ +