diff --git a/src/game/typing/word_flyingsaucer/flyingsaucer.js b/src/game/typing/word_flyingsaucer/flyingsaucer.js new file mode 100644 index 0000000..68d8003 --- /dev/null +++ b/src/game/typing/word_flyingsaucer/flyingsaucer.js @@ -0,0 +1,68 @@ +FlyingSaucer.prototype = Object.create(Phaser.Sprite.prototype); +FlyingSaucer.constructor = FlyingSaucer; + +function FlyingSaucer(lineIndex) { + this.lineIndex = lineIndex; + + this.isActivated = false; + this.speed = FlyingSaucer.DEFAULT_SPEED; + + Phaser.Sprite.call(this, game, game.world.centerX, game.world.centerY, 'alien_normal'); + game.add.existing(this); + game.physics.arcade.enable(this); + + this.scale.set(1); + this.anchor.set(0.5); + this.halfWidth = this.width / 2; + + this.moveInitialPos(); + + // this.setActive(true); +} + + + +FlyingSaucer.prototype.update = function() { + if(this.isActivated) { + var deltaTime = game.time.elapsed / 1000; + this.y += this.speed * deltaTime; + + if(this.y > GAME_SCREEN_SIZE.y - 200) + this.moveInitialPos(); + } else { + this.stop(); + } +} + + +FlyingSaucer.prototype.setup = function(wordLevel, speedLevel) { + this.wordLevel = wordLevel; + this.speedLevel = speedLevel; +} + + + +FlyingSaucer.prototype.stop = function() { + this.body.velocity.setTo(0, 0); +} + +FlyingSaucer.prototype.setActive = function(isActivated) { + this.isActivated = isActivated; +} + +FlyingSaucer.prototype.moveInitialPos = function() { + this.x = 50 + this.lineIndex * 100; + this.y = 100; +} + + + +FlyingSaucer.loadResource = function() { + if(!game.cache.checkImageKey('alien_normal')) + game.load.image('alien_normal', '../../../resources/image/character/alien/green_alien.png'); +} + + + +FlyingSaucer.DEFAULT_SPEED = 10; // dot per sec + diff --git a/src/game/typing/word_flyingsaucer/game.js b/src/game/typing/word_flyingsaucer/game.js index f5dc5f8..e24d9f1 100644 --- a/src/game/typing/word_flyingsaucer/game.js +++ b/src/game/typing/word_flyingsaucer/game.js @@ -44,6 +44,31 @@ var WordFlyingSaucer = { heartGauge.start(); + this.initVariables(); + + for(var i = 0; i < 10; i++) { + var flyingsaucer = new FlyingSaucer(i); + flyingsaucer.setup(this.wordLevel, this.speedLevel); + flyingsaucer.setActive(true); + } + + + + // input text + var INPUT_TEXT_Y = 680; + this.inputText = new InputTypeText(game.world.centerX, INPUT_TEXT_Y); + this.inputText.anchor.set(0.5); + this.inputText.canvasInput.value(''); + this.inputText.canvasInput.focus(); + this.inputText.canvasInput.placeHolder("입력 후 [ Enter ]키를 누르세요"); + // inputText.canvasInput._onkeydown = this.checkInputText; + // inputText.canvasInput._onkeyup = function() { + var self = this; + this.inputText.canvasInput._onkeyup = function() { + self.checkTypingContents(event); + } + + @@ -63,6 +88,12 @@ var WordFlyingSaucer = { location.href = '../../web/client/menu_app.html'; }, + + initVariables: function() { + this.wordLevel = 0; + this.speedLevel = 0; + }, + startGame: function() { }, @@ -91,6 +122,37 @@ var WordFlyingSaucer = { location.href = '../../web/client/result.html'; }, + + checkTypingContents: function(event) { + if(event.keyCode == Phaser.Keyboard.ENTER) { + // console.log("### enter ###"); + var inputContent = this.inputText.canvasInput.value(); + /* + var typingContent = this.typingRandomContents[this.typingIndex]; + + if(inputContent === typingContent) { + this.calculateTypingRecord(typingContent); + this.playNextContent(); + + if(this.typingIndex == this.typingContentLength) + this.gameOver(); + // this.goResult(); + // this.state.start('TypingTestResult'); + } + */ + } + else { + /* + if(this.isTyping == false) { + // console.log(event); + this.setTimeTypingStart(); + } + + this.showTypingContentHighlight(); + */ + } + }, + } diff --git a/src/game/typing/word_flyingsaucer/loading.js b/src/game/typing/word_flyingsaucer/loading.js index 51c74cc..76a46ad 100644 --- a/src/game/typing/word_flyingsaucer/loading.js +++ b/src/game/typing/word_flyingsaucer/loading.js @@ -32,6 +32,8 @@ var Loading = { game.load.image('star', '../../../resources/image/ui/star_particle.png'); HeartGauge.loadResources(); + FlyingSaucer.loadResource(); + // game.load.image('hand_left', '../../../resources/image/ui/hand_left.png'); // game.load.image('hand_right', '../../../resources/image/ui/hand_right.png'); diff --git a/src/web/client/word_flyingsaucer.html b/src/web/client/word_flyingsaucer.html index 1eccbe0..f0cc7a6 100644 --- a/src/web/client/word_flyingsaucer.html +++ b/src/web/client/word_flyingsaucer.html @@ -89,6 +89,7 @@ +