Commit 2d389e71 authored by 18손재민's avatar 18손재민

비정상적인 단어 판별 후 고치는 함수 구현

parents a92e3634 0a5b6941
......@@ -4,7 +4,8 @@
<meta charset="utf-8"/>
<script src="/socket.io/socket.io.js"></script>
<script src="js/phaser.js"></script>
<script src="js/Background.js"></script>
<script src="js/Background.js"></script>]
<script src="js/Input.js"></script>
<script src="js/WordSpace.js"></script>
<script src="js/WordObject.js"></script>
</head>
......
var Input = Input || {};
Input.input = [];
Input.convInput = ""; // converted input
Input.reset = function()
{
Input.input = [];
}
Input.convert = function()
{
// convert input to convInput
}
Input.isEqual = function(inputWord, wordText) { return inputWord === wordText; }
Input.checkProperInput = function(inputWord) { return inputWord === this.removeConVow(inputWord); }
Input.removeConVow = function(_wordText)
{
var tempStr = _wordText;
for(var i = 0; i < _wordText.length; i++)
{
var tempCharCode = _wordText.charCodeAt(i);
if(tempCharCode < 44032 || tempCharCode > 55203)
tempStr = tempStr.replace(String.fromCharCode(parseInt(tempCharCode.toString(16), 16)), '');
}
return tempStr;
}
Input.inputField =
{
generate: function(scene)
{
this.background = scene.add.sprite(400, 500, 'inputFieldBackground').setScale(0.2);
this.text = scene.add.text(400, 500, "안녕하세요", {font: '15pt 궁서'}).setOrigin(0.5, 0.5).setColor('#000000');
},
loadImage: function(scene)
{
scene.load.image('inputFieldBackground', 'assets/inputFieldBackground.png');
}
}
\ No newline at end of file
......@@ -2,11 +2,37 @@ var WordSpace = WordSpace || {};
WordSpace.isImageLoaded = false;
WordSpace.wordGroup = null;
WordSpace.nextWordCode = 0;
WordSpace.wordGroup = [];
WordSpace.wordForcedGroup = [];
WordSpace.wordPhysicsGroup = null;
WordSpace.gravityPoint = {x: 400, y: 300};
WordSpace.wordCycle = null;
WordSpace.resetCycle = function(scene, _delay)
{
var option =
{
delay: _delay,
callback: function()
{
WordSpace.generateWord(this)
},
callbackScope: scene,
loop: true
};
if (this.wordCycle != null)
{
this.wordCycle = this.wordCycle.reset(option);
}
else
{
this.wordCycle = scene.time.addEvent(option);
}
}
WordSpace.loadImage = function(scene)
{
if (!this.isImageLoaded)
......@@ -14,3 +40,14 @@ WordSpace.loadImage = function(scene)
scene.load.image('wordBackground', 'assets/wordBackground.png');
}
}
WordSpace.generateWord = function(scene)
{
word = new WordObject("솽젠커");
word.instantiate(scene);
WordSpace.wordGroup.push(word);
WordSpace.wordForcedGroup.push(word);
scene.physics.add.collider(word.physicsObj, WordSpace.wordPhysicsGroup);
scene.physics.add.collider(word.physicsObj, BackGround.brainGroup);
WordSpace.wordPhysicsGroup.add(word.physicsObj);
}
\ No newline at end of file
......@@ -18,45 +18,28 @@ var config = {
var game = new Phaser.Game(config);
var tec;
// load assets
function preload()
{
BackGround.loadImage(this);
WordSpace.loadImage(this);
Input.inputField.loadImage(this);
}
function create()
{
BackGround.drawBrain(this);
WordSpace.wordGroup = [];
Input.inputField.generate(this);
WordSpace.wordPhysicsGroup = this.physics.add.group();
this.time.addEvent(
{
delay: 2000,
callback: function()
{
var word = new WordObject("치또이쯔");
word.generate(this);
console.log(word.getWordWeight() + " " + word.wordTyping);
WordSpace.wordGroup.push(word);
this.physics.add.collider(word.physicsObj, WordSpace.wordPhysicsGroup);
WordSpace.wordPhysicsGroup.add(word.physicsObj);
},
callbackScope: this,
repeat: 10
}
);
WordSpace.resetCycle(this, 2000);
}
function update()
{
for(i = 0; i < WordSpace.wordGroup.length; i++)
WordSpace.wordForcedGroup.forEach(function(element)
{
WordSpace.wordGroup[i].attract(0.3);
}
element.attract(0.3);
});
}
var socket = io.connect();
......
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