From ead099fc0580fbfddb5f629925d98ba8e872d33c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Thu, 10 May 2018 19:09:43 +0900 Subject: [PATCH] Add: space invaders game --- src/game/global/global_variables.js | 6 ++ src/game/lib/app_info_manager.js | 6 ++ src/game/mouse/space_invaders/game.js | 34 +++++++++ src/game/mouse/space_invaders/loading.js | 94 ++++++++++++++++++++++++ src/game/mouse/space_invaders/main.js | 7 +- src/game/start/start.js | 5 +- src/web/client/space_invaders.html | 11 +++ 7 files changed, 158 insertions(+), 5 deletions(-) create mode 100644 src/game/mouse/space_invaders/game.js create mode 100644 src/game/mouse/space_invaders/loading.js diff --git a/src/game/global/global_variables.js b/src/game/global/global_variables.js index c850375..b487d98 100644 --- a/src/game/global/global_variables.js +++ b/src/game/global/global_variables.js @@ -22,6 +22,12 @@ const GAME_SCREEN_SIZE = { x: 1024, y: 768 } let sessionStorageManager = new SessionStorageManager(); { + if(isDebugMode()) { + sessionStorageManager.playerName = "박지상"; + sessionStorageManager.playerUserID = 1; + sessionStorageManager.playingAppName = "space_invaders"; + } + console.log("playerName : " + sessionStorageManager.playerName); console.log("playerUserID : " + sessionStorageManager.playerUserID); console.log("playingAppName : " + sessionStorageManager.playingAppName); diff --git a/src/game/lib/app_info_manager.js b/src/game/lib/app_info_manager.js index 408e177..911c5d2 100644 --- a/src/game/lib/app_info_manager.js +++ b/src/game/lib/app_info_manager.js @@ -40,10 +40,16 @@ class AppInfoManager { } getAppNameKorean(name) { + if(name === null) + return ""; + return this.appInfoMap[name].nameKorean; } getHowToPlayText(name) { + if(name === null) + return ""; + return this.appInfoMap[name].howToPlay; } diff --git a/src/game/mouse/space_invaders/game.js b/src/game/mouse/space_invaders/game.js new file mode 100644 index 0000000..12ba4e9 --- /dev/null +++ b/src/game/mouse/space_invaders/game.js @@ -0,0 +1,34 @@ +///////////////////////////// +// Space invaders game + +class Game { + + create() { + // this.historyRecordManager = new HistoryRecordManager(); + + this.game.stage.backgroundColor = '#4d4d4d'; + // this.chartGraphics = game.add.graphics(100, game.world.height - 120); + + + // top + let backButton = new BackButton( () => { + location.href = '../../web/client/menu_app.html'; + }); + + let fullscreenButton = new FullscreenButton(this.game); + + + // contents + + + // bottom + let screenBottom = new ScreenBottom(game); + screenBottom.makeBottomLine(); + screenBottom.printBottomLeftText("게임 진행 정보"); + let playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName); + screenBottom.printBottomCenterText(playingAppName); + screenBottom.printBottomRightText(sessionStorageManager.playerName); + } + + +} \ No newline at end of file diff --git a/src/game/mouse/space_invaders/loading.js b/src/game/mouse/space_invaders/loading.js new file mode 100644 index 0000000..02c481f --- /dev/null +++ b/src/game/mouse/space_invaders/loading.js @@ -0,0 +1,94 @@ +///////////////////////////// +// Loading + +// var x = 32; +// var y = 80; + +class Loading { + + preload() { + // this.game.load.image('loadingbar', './image/phaser.png'); + } + + create() { + // let userID = sessionStorage.getItem("UserID"); + // console.log("userID : " + userID); + + // this.game.stage.backgroundColor = '#4d4d4d'; + + // // Progress report + // this.textProgress = game.add.text(game.world.centerX, 100, '로딩중 . . .', textStyleBasic); + // this.textProgress.anchor.setTo(0.5, 0.4); + // this.textProgress.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); + + // // Preload bar + // this.preloadBar = this.add.sprite(game.world.centerX, game.world.centerY, 'loadingbar'); + // this.preloadBar.anchor.setTo(0.5); + // this.preloadBar.alpha = 0; + + this.game.load.onFileComplete.add(this.fileComplete, this); + this.game.load.onLoadComplete.add(this.loadComplete, this); + + this.startLoading(); + } + + startLoading() { + this.game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); + // this.game.load.image('a', '../../../resources/image/icon/fullscreen_white.png'); + // this.game.load.image('b', '../../../resources/image/icon/fullscreen_white.png'); + // this.game.load.image('c', '../../../resources/image/icon/fullscreen_white.png'); + // this.game.load.image('d', '../../../resources/image/icon/fullscreen_white.png'); + // this.game.load.image('a', './image/phaser.png'); + // this.game.load.image('b', './image/phaser.png'); + // this.game.load.image('c', './image/phaser.png'); + // this.game.load.image('d', './image/phaser.png'); + // this.game.load.image('e', './image/phaser.png'); + // this.game.load.image('g', './image/phaser.png'); + // this.game.load.image('e', './image/phaser.png'); + // this.game.load.image('f', './image/phaser.png'); + // this.game.load.image('g', './image/phaser.png'); + // this.game.load.image('h', './image/phaser.png'); + + // this.game.load.image('phaser', './image/phaser.png'); + // this.game.load.spritesheet('button', './image/button_basic.png', 200, 100); + // this.game.load.image('star', './image/star_particle.png'); + // this.game.load.image('medal_gold', './image/medal_gold.png'); + // this.game.load.image('medal_silver', './image/medal_silver.png'); + // this.game.load.image('medal_bronze', './image/medal_bronze.png'); + + this.game.load.start(); + } + + fileComplete(progress, cacheKey, success, totalLoaded, totalFiles) { + // this.preloadBar.alpha = progress / 100; + + // console.log('progress : ' + progress); + + // text.setText("File Complete: " + progress + "% - " + totalLoaded + " out of " + totalFiles); + + // var newImage = game.add.image(x, y, cacheKey); + // newImage.scale.set(0.3); + + // x += newImage.width + 20; + // if (x > 700) + // { + // x = 32; + // y += 332; + // } + } + + loadComplete(progress, cacheKey, success, totalLoaded, totalFiles) { + // this.preloadBar.alpha = 1; + + if(isDebugMode()) { + sessionStorage + this.state.start('Game'); + return; + } + + this.state.start('Game'); + // this.startMenu(); + // this.startTypingTestStage(); + // this.startTypingTestResult(); + } +} diff --git a/src/game/mouse/space_invaders/main.js b/src/game/mouse/space_invaders/main.js index 06dd254..55e0a87 100644 --- a/src/game/mouse/space_invaders/main.js +++ b/src/game/mouse/space_invaders/main.js @@ -3,10 +3,13 @@ const CONTENT_ID = "Space Invaders"; -var game = new Phaser.Game(960, 540, Phaser.CANVAS, CONTENT_ID); +let game = new Phaser.Game( + GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y, + Phaser.CANVAS, CONTENT_ID +); game.state.add('Loading', Loading); game.state.start('Loading'); -// game.state.add('Login', Login); +game.state.add('Game', Game); // game.state.add('Menu', Menu); diff --git a/src/game/start/start.js b/src/game/start/start.js index 6fda8c5..91e2e1b 100644 --- a/src/game/start/start.js +++ b/src/game/start/start.js @@ -59,7 +59,7 @@ let Start = { loadHistoryRecords: function() { this.historyRecordManager.clear(); - + this.historyRecordManager.push(new HistoryRecordData("05/10", 15460)); this.historyRecordManager.push(new HistoryRecordData("05/11", 13040)); this.historyRecordManager.push(new HistoryRecordData("05/12", 16460)); @@ -122,8 +122,7 @@ let Start = { }, startStage: function() { - console.log("startStage"); - // this.startState('TypingTestStage'); + location.href = "../../web/client/" + sessionStorageManager.playingAppName + ".html"; }, } \ No newline at end of file diff --git a/src/web/client/space_invaders.html b/src/web/client/space_invaders.html index f43efaa..1bce0ce 100644 --- a/src/web/client/space_invaders.html +++ b/src/web/client/space_invaders.html @@ -14,8 +14,19 @@ + + + + + + + + + + +