Add: choco tile

This commit is contained in:
2019-01-08 21:09:30 +09:00
parent 59823e42a6
commit 410bc2c0c7
8 changed files with 182 additions and 30 deletions
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 897 B

+47
View File
@@ -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;
@@ -37,16 +37,22 @@ function FlyingSaucer(lineIndex) {
this.explodeEmitter = this.makeExplodeEmitter(); 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 = 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.wordText.anchor.set(0.5);
this.setActive(true); this.setActive(false);
this.setVisible(false);
} }
FlyingSaucer.prototype.initVariables = function() { FlyingSaucer.prototype.initVariables = function() {
this.isActivated = false; this.isActivated = false;
this.isGameOver = false;
this.wordLevel = 0; this.wordLevel = 0;
this.difficultyForLevel = 0; this.difficultyForLevel = 0;
this.standardScore = 0; this.standardScore = 0;
@@ -58,7 +64,9 @@ FlyingSaucer.prototype.initVariables = function() {
this.extractWordManager = null; this.extractWordManager = null;
this.gameLevelManager = null; this.gameLevelManager = null;
this.timerEvent = null; this.timerEventExplode = null;
this.tweenScale = null;
} }
FlyingSaucer.prototype.makeCockpit = function(posX, posY) { FlyingSaucer.prototype.makeCockpit = function(posX, posY) {
@@ -98,6 +106,9 @@ FlyingSaucer.prototype.makeExplodeEmitter = function() {
FlyingSaucer.prototype.update = function() { FlyingSaucer.prototype.update = function() {
if(this.isGameOver)
return;
if(this.isActivated) { if(this.isActivated) {
var deltaTime = game.time.elapsed / 1000; var deltaTime = game.time.elapsed / 1000;
this.y += this.speed * deltaTime; this.y += this.speed * deltaTime;
@@ -165,8 +176,12 @@ FlyingSaucer.prototype.stop = function() {
FlyingSaucer.prototype.setActive = function(isActivated) { FlyingSaucer.prototype.setActive = function(isActivated) {
this.isActivated = isActivated; this.isActivated = isActivated;
}
if(this.isActivated) FlyingSaucer.prototype.setVisible = function(isVisible) {
this.isVisible = isVisible;
if(this.isVisible)
this.alpha = 1; this.alpha = 1;
else else
this.alpha = 0; this.alpha = 0;
@@ -175,6 +190,9 @@ FlyingSaucer.prototype.setActive = function(isActivated) {
FlyingSaucer.prototype.moveInitialPos = function() { FlyingSaucer.prototype.moveInitialPos = function() {
this.x = 100 + this.lineIndex * 200; this.x = 100 + this.lineIndex * 200;
this.y = FlyingSaucer.START_POS_Y; this.y = FlyingSaucer.START_POS_Y;
this.scale.set(1);
this.speed += FlyingSaucer.SPEED_UP_AMOUNT; this.speed += FlyingSaucer.SPEED_UP_AMOUNT;
this.changeCockpitColor(); this.changeCockpitColor();
@@ -189,6 +207,9 @@ FlyingSaucer.prototype.moveInitialPos = function() {
FlyingSaucer.prototype.startAttack = function() { FlyingSaucer.prototype.startAttack = function() {
if(this.isGameOver)
return;
this.wordLevel = this.gameLevelManager.getWordLevel(); this.wordLevel = this.gameLevelManager.getWordLevel();
this.difficultyForLevel = this.gameLevelManager.getDifficultyForLevel(this.wordLevel); this.difficultyForLevel = this.gameLevelManager.getDifficultyForLevel(this.wordLevel);
// console.log("===="); // console.log("====");
@@ -202,6 +223,7 @@ FlyingSaucer.prototype.startAttack = function() {
this.moveInitialPos(); this.moveInitialPos();
this.setActive(true); this.setActive(true);
this.setVisible(true);
} }
FlyingSaucer.prototype.checkInputText = function(inputText) { FlyingSaucer.prototype.checkInputText = function(inputText) {
@@ -252,8 +274,9 @@ FlyingSaucer.prototype.checkWord = function(inputText) {
if(this.word == inputText) { if(this.word == inputText) {
this.gameLevelManager.clearWord(this.wordLevel, this.getLandingRatio()); this.gameLevelManager.clearWord(this.wordLevel, this.getLandingRatio());
this.extractWordManager.removeWord(this.wordLevel, this.word); this.extractWordManager.removeWord(this.wordLevel, this.word);
this.setWord("");
this.setActive(false); this.setActive(false);
this.setVisible(false);
this.setWord("");
this.explode(); this.explode();
this.plusScore(); this.plusScore();
@@ -267,7 +290,7 @@ FlyingSaucer.prototype.explode = function(inputText) {
this.explodeEmitter.start(true, 1000, null, 100); this.explodeEmitter.start(true, 1000, null, 100);
var randomDelayTime = Phaser.Timer.SECOND / 2 + Math.random() * Phaser.Timer.SECOND * 3; 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) { FlyingSaucer.prototype.plusScore = function(inputText) {
@@ -279,16 +302,42 @@ FlyingSaucer.prototype.plusScore = function(inputText) {
} }
FlyingSaucer.prototype.crash = function() { 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); this.heartManager.breakHearts(1);
} }
FlyingSaucer.prototype.destroy = function() { FlyingSaucer.prototype.respawn = function() {
if(this.timerEvent) this.tweenScale = null;
game.time.events.remove(this.timerEvent);
if(this.isGameOver) {
this.setActive(false); this.setActive(false);
this.setVisible(false);
this.setWord(""); 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_UP_AMOUNT = 4; // dot per sec
FlyingSaucer.SPEED_DOWN_AMOUNT = FlyingSaucer.SPEED_UP_AMOUNT / 2; // 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_NORMAL = "#000000";
FlyingSaucer.TEXT_COLOR_CORRECT = "#ffff4d"; FlyingSaucer.TEXT_COLOR_CORRECT = "#ffff4d";
FlyingSaucer.TEXT_STROKE_COLOR = "#ffffff";
FlyingSaucer.JET_STATUS_HIGH = 0; FlyingSaucer.JET_STATUS_HIGH = 0;
FlyingSaucer.JET_STATUS_MIDDLE = 1; FlyingSaucer.JET_STATUS_MIDDLE = 1;
FlyingSaucer.JET_STATUS_LOW = 2; FlyingSaucer.JET_STATUS_LOW = 2;
FlyingSaucer.JET_COLOR_HIGH = 0x00ffff; FlyingSaucer.JET_COLOR_HIGH = 0x00ff00; //0x00ffff;
FlyingSaucer.JET_COLOR_MIDDLE = 0xffff00; FlyingSaucer.JET_COLOR_MIDDLE = 0xffff00; //0xffff00;
FlyingSaucer.JET_COLOR_LOW = 0xff0000; FlyingSaucer.JET_COLOR_LOW = 0xff0000;
FlyingSaucer.COKCPIT_COLOR = [ FlyingSaucer.COKCPIT_COLOR = [
0xff0000, 0xff6600, 0xffff00, 0x00ffff, 0x00ffff, 0x6666ff, 0xff00ff // 0xff0000, 0xff6600, 0xffff00, 0x00ffff, 0x00ffff, 0x6666ff, 0xff00ff
0x00ffff, 0x55aacc, 0x0000ff, 0x8800cc, 0xff00ff, 0x6666ff, 0xff00ff
] ]
+59 -11
View File
@@ -37,12 +37,7 @@ var WordFlyingSaucer = {
// game stage // game stage
this.game.stage.backgroundColor = "#000000"; // '#4d4d4d'; this.drawBackground();
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.flyingsaucers = []; this.flyingsaucers = [];
for(var i = 0; i < WordFlyingSaucer.MAX_FLYINGSAUCER_COUNT; i++) { 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].setHeartManager(this.heartManager);
this.flyingsaucers[i].setExtractWordManager(this.extractWordManager); this.flyingsaucers[i].setExtractWordManager(this.extractWordManager);
this.flyingsaucers[i].setGameLevelManager(this.gameLevelManager); this.flyingsaucers[i].setGameLevelManager(this.gameLevelManager);
this.flyingsaucers[i].setActive(true);
this.flyingsaucers[i].startAttack(); this.flyingsaucers[i].startAttack();
} }
@@ -83,9 +77,6 @@ var WordFlyingSaucer = {
} }
// bottom ui // bottom ui
this.screenBottomUI = new ScreenBottomUI(); this.screenBottomUI = new ScreenBottomUI();
// screenBottomUI.printBottomUILeftText(""); // screenBottomUI.printBottomUILeftText("");
@@ -105,9 +96,55 @@ var WordFlyingSaucer = {
initVariables: function() { initVariables: function() {
this.extractWordManager = new ExtractWordManager(); this.extractWordManager = new ExtractWordManager();
this.gameLevelManager = new GameLevelManager(); this.gameLevelManager = new GameLevelManager(this);
this.speedLevel = 0; 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() { 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; WordFlyingSaucer.MAX_FLYINGSAUCER_COUNT = 5;
WordFlyingSaucer.COLOR_ATMOSPHERE_OUTSIDE = 0x000000;
WordFlyingSaucer.COLOR_ATMOSPHERE_INSIDE = 0x444400;
WordFlyingSaucer.COLOR_ATMOSPHERE_HORIZON = 0x440000;
@@ -1,4 +1,6 @@
function GameLevelManager() { function GameLevelManager(mainGame) {
this.mainGame = mainGame;
this.wordLevel = 0; this.wordLevel = 0;
this.clearedWordCountForLevel = [0, 0, 0, 0, 0, 0]; this.clearedWordCountForLevel = [0, 0, 0, 0, 0, 0];
@@ -78,12 +80,14 @@ GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel
GameLevelManager.prototype.goNextWordLevel = function() { GameLevelManager.prototype.goNextWordLevel = function() {
this.wordLevel++; this.wordLevel++;
this.mainGame.showLevelUpText();
// console.log("goNextWordLevel to " + this.wordLevel); // console.log("goNextWordLevel to " + this.wordLevel);
} }
GameLevelManager.LEVEL_UP_LANDING_RATIO = 0.7; GameLevelManager.LEVEL_UP_LANDING_RATIO = 0.7;
GameLevelManager.WARNING_LANDING_RATIO = 0.1; GameLevelManager.WARNING_LANDING_RATIO = 0.3;
GameLevelManager.MAX_WORD_LEVEL = 6; GameLevelManager.MAX_WORD_LEVEL = 6;
@@ -29,6 +29,7 @@ var Loading = {
startLoading: function() { startLoading: function() {
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); 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'); game.load.image('star', '../../../resources/image/background/star_7x7.png');
HeartGauge.loadResources(); HeartGauge.loadResources();
+1
View File
@@ -48,6 +48,7 @@
<script src="../../game/lib/util/record_util.js"></script> <script src="../../game/lib/util/record_util.js"></script>
<script src="../../game/lib/text/input_type_text.js?update_date=191224"></script> <script src="../../game/lib/text/input_type_text.js?update_date=191224"></script>
<script src="../../game/lib/text/center_message_text.js?update_date=191224"></script>
<script src="../../game/lib/text/game_over_text.js?update_date=191224"></script> <script src="../../game/lib/text/game_over_text.js?update_date=191224"></script>
<script src="../../game/lib/text/time_over_text.js?update_date=191224"></script> <script src="../../game/lib/text/time_over_text.js?update_date=191224"></script>
<script src="../../game/lib/text/score_board.js?update_date=191224"></script> <script src="../../game/lib/text/score_board.js?update_date=191224"></script>