Commit 6150db4b authored by 18신대성's avatar 18신대성 Committed by 18류지석

메뉴씬 만듬

parent ec721f06
var BackGround = BackGround || {} var BackGround = BackGround || {}
BackGround.isImageLoaded = false;
BackGround.brainGroup = null; BackGround.brainGroup = null;
BackGround.loadImage = function(scene) BackGround.loadImage = function(scene)
{ {
if (!this.isImageLoaded) scene.load.image('brainGround', 'assets/placeholder/playback.png');
{ scene.load.image('menuBackground', 'assets/placeholder/menuBackground.png')
scene.load.image('brainGround0', 'assets/placeholder/playback.png');
}
} }
BackGround.drawBrain = function(scene) BackGround.drawBrain = function(scene)
{ {
brains = scene.add.sprite(640, 360, 'brainGround0').setDisplaySize(1282, 722).setDepth(1); brains = scene.add.sprite(640, 360, 'brainGround').setDisplaySize(1282, 722).setDepth(1);
}
BackGround.drawMenu = function(scene)
{
scene.add.sprite(640, 360, 'menuBackground').setDisplaySize(1282, 722).setDepth(1);
} }
\ No newline at end of file
...@@ -11,6 +11,23 @@ Input.maxInput = 5; ...@@ -11,6 +11,23 @@ Input.maxInput = 5;
Input.attackMode = false; Input.attackMode = false;
Input.attackOption = null; Input.attackOption = null;
Input.gameSceneEnterReaction = function()
{
Input.convInput = Input.removeConVow(Input.convInput);
if (Input.attackMode) WordSpace.attack(Input.convInput, Input.attackOption.wordGrade);
else WordSpace.findWord(Input.convInput);
WordSpace.resetGameOverTimer();
Input.reset();
}
Input.menuSceneEnterReaction = function()
{
Input.convInput = Input.removeConVow(Input.convInput);
console.log('닉네임은 ' + Input.convInput);
Input.reset();
game.scene.start('gameScene');
game.scene.remove('menuScene');
}
Input.reset = function() Input.reset = function()
{ {
Input.input = []; Input.input = [];
...@@ -275,7 +292,7 @@ Input.removeConVow = function(_wordText) ...@@ -275,7 +292,7 @@ Input.removeConVow = function(_wordText)
Input.inputField = Input.inputField =
{ {
generate: function(scene) generate: function(scene, enterCallback)
{ {
this.background = scene.add.sprite(640, 550, 'inputfield').setDepth(10); this.background = scene.add.sprite(640, 550, 'inputfield').setDepth(10);
this.text = scene.add.text(640, 550, "안녕하세요", {font: '25pt 궁서'}).setOrigin(0.5, 0.5).setColor('#000000').setDepth(10); this.text = scene.add.text(640, 550, "안녕하세요", {font: '25pt 궁서'}).setOrigin(0.5, 0.5).setColor('#000000').setDepth(10);
...@@ -293,14 +310,7 @@ Input.inputField = ...@@ -293,14 +310,7 @@ Input.inputField =
Input.inputField.text.setText(Input.convInput); Input.inputField.text.setText(Input.convInput);
} }
}); });
scene.input.keyboard.on('keydown-ENTER', function() scene.input.keyboard.on('keydown-ENTER', enterCallback);
{
Input.convInput = Input.removeConVow(Input.convInput);
if (Input.attackMode) WordSpace.attack(Input.convInput, Input.attackOption.wordGrade);
else WordSpace.findWord(Input.convInput);
WordSpace.resetGameOverTimer();
Input.reset();
});
// upside 10 keys // upside 10 keys
scene.input.keyboard.on('keydown-Q', function() {Input.pushInput('')}); scene.input.keyboard.on('keydown-Q', function() {Input.pushInput('')});
scene.input.keyboard.on('keydown-W', function() {Input.pushInput('')}); scene.input.keyboard.on('keydown-W', function() {Input.pushInput('')});
......
...@@ -11,12 +11,14 @@ var menuScene = new Phaser.Class( ...@@ -11,12 +11,14 @@ var menuScene = new Phaser.Class(
preload: function() preload: function()
{ {
//Input.inputField.loadImage(this); Input.inputField.loadImage(this);
BackGround.loadImage(this);
}, },
create: function() create: function()
{ {
//Input.inputField.generate(this); Input.inputField.generate(this, Input.menuSceneEnterReaction);
BackGround.drawMenu(this);
}, },
update: function() update: function()
...@@ -51,7 +53,7 @@ var gameScene = new Phaser.Class( ...@@ -51,7 +53,7 @@ var gameScene = new Phaser.Class(
WordSpace.wordPhysicsGroup = this.physics.add.group(); WordSpace.wordPhysicsGroup = this.physics.add.group();
Input.inputField.generate(this); Input.inputField.generate(this, Input.gameSceneEnterReaction);
WordSpace.attackGauge.generate(this); WordSpace.attackGauge.generate(this);
WordSpace.spaceInitiate(this); WordSpace.spaceInitiate(this);
......
...@@ -9,7 +9,7 @@ var config = { ...@@ -9,7 +9,7 @@ var config = {
} }
}, },
backgroundColor: Phaser.Display.Color.GetColor(0,0,0), backgroundColor: Phaser.Display.Color.GetColor(0,0,0),
scene: [ gameScene, menuScene ] scene: [ menuScene, gameScene ]
}; };
var game = new Phaser.Game(config) var game = new Phaser.Game(config)
...@@ -25,31 +25,31 @@ socket.on('idSet', function(msg) // {str, num} ...@@ -25,31 +25,31 @@ socket.on('idSet', function(msg) // {str, num}
}); });
//test //test
window.addEventListener("message", function(event) /*
{ window.addEventListener("message", function (event) {
var sub = 0; var sub = 0;
if(event.data == "tick"){ if (event.data == "tick") {
if(window.lafcb) if (window.lafcb)
if((new Date().getTime()/1000) - window.lafcb.started > 0.5){ if ((new Date().getTime() / 1000) - window.lafcb.started > 0.5) {
window.lafcb.func(new Date().getTime()+16) window.lafcb.func(new Date().getTime() + 16)
window.lafcb = null; window.lafcb = null;
} }
var i = window.timeouts.length; var i = window.timeouts.length;
while (i--) { while (i--) {
if(window.timeouts[i].ran){ if (window.timeouts[i].ran) {
window.timeouts.splice(i,1); window.timeouts.splice(i, 1);
} }
} }
var i = window.timeouts.length; var i = window.timeouts.length;
while (i--) { while (i--) {
if(new Date().getTime() - window.timeouts[i].started >= window.timeouts[i].delay && window.timeouts[i]){ if (new Date().getTime() - window.timeouts[i].started >= window.timeouts[i].delay && window.timeouts[i]) {
window.timeouts[i].func(); window.timeouts[i].func();
window.timeouts[i].ran = true; window.timeouts[i].ran = true;
} }
} }
for(var i in window.intervals){ for (var i in window.intervals) {
var currTime = new Date().getTime(); var currTime = new Date().getTime();
if(currTime - window.intervals[i].last >= window.intervals[i].delay && window.intervals[i]){ if (currTime - window.intervals[i].last >= window.intervals[i].delay && window.intervals[i]) {
window.intervals[i].last = currTime; window.intervals[i].last = currTime;
window.intervals[i].func(); window.intervals[i].func();
} }
...@@ -57,63 +57,63 @@ window.addEventListener("message", function(event) ...@@ -57,63 +57,63 @@ window.addEventListener("message", function(event)
window.postMessage('tick', '*'); window.postMessage('tick', '*');
} }
}, false); }, false);
(function(context) { (function (context) {
'use strict'; 'use strict';
window.lafcb = null; window.lafcb = null;
context.timeouts = []; context.timeouts = [];
context.intervals = []; context.intervals = [];
var lastTime = new Date().getTime(); var lastTime = new Date().getTime();
context.old = {}; context.old = {};
old.setTimeout = (i,ii)=> context.setTimeout(i,ii); old.setTimeout = (i, ii) => context.setTimeout(i, ii);
old.setInterval = (i,ii) =>context.setInterval(i,ii); old.setInterval = (i, ii) => context.setInterval(i, ii);
old.clearTimeout = (i) =>context.clearTimeout(i); old.clearTimeout = (i) => context.clearTimeout(i);
old.clearInterval = (i) =>context.clearInterval(i); old.clearInterval = (i) => context.clearInterval(i);
if(typeof(context.postMessage) == 'function'){ if (typeof (context.postMessage) == 'function') {
context.setTimeout = function(fn, millis) { context.setTimeout = function (fn, millis) {
var id = timeouts.length var id = timeouts.length
timeouts[id] = {id: id,func: fn, delay: millis,started: new Date().getTime()}; timeouts[id] = { id: id, func: fn, delay: millis, started: new Date().getTime() };
return id; return id;
}; };
context.clearTimeout = function(cancel) { context.clearTimeout = function (cancel) {
for(var i in timeouts){ for (var i in timeouts) {
if(timeouts[i].id == cancel){ if (timeouts[i].id == cancel) {
timeouts.splice(i,1); timeouts.splice(i, 1);
break; break;
} }
} }
}; };
context.setInterval = function(fn, delay ) { context.setInterval = function (fn, delay) {
intervals[intervals.length] = {func: fn, delay: delay,last: new Date().getTime()}; intervals[intervals.length] = { func: fn, delay: delay, last: new Date().getTime() };
return intervals[intervals.length-1]; return intervals[intervals.length - 1];
}; };
context.clearInterval = function(cancel) { context.clearInterval = function (cancel) {
for(var i in intervals){ for (var i in intervals) {
if(intervals[i] == cancel){ if (intervals[i] == cancel) {
intervals.splice(i,1); intervals.splice(i, 1);
break; break;
} }
} }
}; };
} }
context.requestAnimationFrame = function( callback, element ) { context.requestAnimationFrame = function (callback, element) {
lafcb = {started: new Date().getTime()/1000,func: callback}; lafcb = { started: new Date().getTime() / 1000, func: callback };
var currTime = new Date().getTime(); var currTime = new Date().getTime();
var timeToCall = 16; var timeToCall = 16;
var id = context.setTimeout( function() { var id = context.setTimeout(function () {
callback( currTime+timeToCall); callback(currTime + timeToCall);
}, timeToCall ); }, timeToCall);
return id; return id;
}; };
context.cancelAnimationFrame = function( id ) { context.cancelAnimationFrame = function (id) {
lafcb lafcb
context.clearTimeout( id ); context.clearTimeout(id);
}; };
context.addEventListener("load",function(){ context.addEventListener("load", function () {
if(typeof(context.postMessage) == 'function'){ if (typeof (context.postMessage) == 'function') {
context.postMessage('tick', '*'); context.postMessage('tick', '*');
}else{ } else {
context.setTimeout = old.setTimeout context.setTimeout = old.setTimeout
context.setInterval = old.setInterval context.setInterval = old.setInterval
context.clearTimeout = old.clearTimeout context.clearTimeout = old.clearTimeout
...@@ -121,4 +121,4 @@ window.addEventListener("message", function(event) ...@@ -121,4 +121,4 @@ window.addEventListener("message", function(event)
alert("Your browser does not support postMessage. Sorry but you will be forced to default to the standard setInterval and setTimeout functions. This means you may experience pauses in your game when you navigate away from the tab it is playing in."); alert("Your browser does not support postMessage. Sorry but you will be forced to default to the standard setInterval and setTimeout functions. This means you may experience pauses in your game when you navigate away from the tab it is playing in.");
} }
}); });
})(this); })(this);*/
\ No newline at end of file
...@@ -48,7 +48,7 @@ GameServer.makeRoom = function() ...@@ -48,7 +48,7 @@ GameServer.makeRoom = function()
var roomOption = var roomOption =
{ {
roomNum: GameServer.nextRoomNumber++, roomNum: GameServer.nextRoomNumber++,
maxPlayer: 25, maxPlayer: 3,
currentPlayer: [] currentPlayer: []
} }
this.playingRoom.push(roomOption); this.playingRoom.push(roomOption);
...@@ -110,6 +110,8 @@ io.on('connection', function(socket) ...@@ -110,6 +110,8 @@ io.on('connection', function(socket)
{ {
console.log('client disconnected, id: ' + GameServer.currentPlayer[idxToDel].id + ', reason: ' + reason); console.log('client disconnected, id: ' + GameServer.currentPlayer[idxToDel].id + ', reason: ' + reason);
GameServer.currentPlayer.splice(idxToDel, 1); GameServer.currentPlayer.splice(idxToDel, 1);
// 룸에서도 제거
// 모두에게 삭제했다고 보내기
} }
}); });
}); });
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment