From 54a65d2513905677fa3343f825f3671ba0f148c7 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: Fri, 10 May 2019 20:21:59 +0900 Subject: [PATCH] Fix: chocoball slot --- src/game/mouse/one_to_fifty/chocoball.js | 36 +++++++++------- src/game/mouse/one_to_fifty/game.js | 55 +++++++++++++----------- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/src/game/mouse/one_to_fifty/chocoball.js b/src/game/mouse/one_to_fifty/chocoball.js index aa2ae09..8788e7d 100644 --- a/src/game/mouse/one_to_fifty/chocoball.js +++ b/src/game/mouse/one_to_fifty/chocoball.js @@ -15,24 +15,14 @@ function Chocoball(index, difficulty, onClickHandler) { Chocoball.prototype.initVariables = function(textContent) { this.isActivated = false; this.number = 0; - - if(this.index == 100) { - this.col = 6.4; - this.row = 0.85; - } else { - this.row = Math.floor(this.index / 5); - this.col = this.index % 5; - } } Chocoball.prototype.drawChocoball = function() { - var x = 200 + this.col * 100; - var y = 200 + this.row * 100; + var x = Chocoball.getX(this.index); + var y = Chocoball.getY(this.index); this.body = game.add.sprite(x, y, 'choco_body'); - this.body.scale.set(1); + // this.body.scale.set(1); this.body.anchor.set(0.5); - this.body.tint = 0x553333; - // this.body.tint = 0xff0000; this.body.inputEnabled = true; this.body.events.onInputDown.add(this.onClick, this); @@ -42,7 +32,7 @@ Chocoball.prototype.drawChocoball = function() { this.body.addChild(this.numberText); this.gloss = game.add.sprite(x, y, 'choco_gloss'); - this.gloss.scale.set(1); + // this.gloss.scale.set(1); this.gloss.anchor.set(0.5); } @@ -99,6 +89,20 @@ Chocoball.prototype.onClick = function() { } +Chocoball.getX = function(index) { + if(index == 100) + return 840; + + return 200 + (index % 5) * 100; +} + +Chocoball.getY = function(index) { + if(index == 100) + return 285; + + return 200 + (Math.floor(index / 5)) * 100; +} + Chocoball.loadResources = function() { game.load.image('choco_gloss', '../../../resources/image/object/one_to_fifty/choco_gloss.png'); game.load.image('choco_body', '../../../resources/image/object/one_to_fifty/choco_body.png'); @@ -111,7 +115,7 @@ Chocoball.IMAGE_SIZE = 90; Chocoball.IMAGE_CENTER = Chocoball.IMAGE_SIZE / 2; Chocoball.FONT_STYLE = { - font: "50px Arial", + font: "40px Arial", boundsAlignH: "center", // left, center. right boundsAlignV: "middle", // top, middle, bottom fill: "#fff", @@ -124,6 +128,8 @@ Chocoball.FONT_STYLE = { Chocoball.DEFAULT_TEXT_LINE_SPACING_PX = -10; // in pixel Chocoball.DEFAULT_STROKE_WIDTH_PX = 5; // in pixel +Chocball.RADIUS = 90; + Chocoball.COLOR_BLACK = 0x553333; Chocoball.COLOR_1_TO_10 = 0x3355ff; Chocoball.COLOR_11_TO_20 = 0xff5533; diff --git a/src/game/mouse/one_to_fifty/game.js b/src/game/mouse/one_to_fifty/game.js index ee57bef..d5a66f3 100644 --- a/src/game/mouse/one_to_fifty/game.js +++ b/src/game/mouse/one_to_fifty/game.js @@ -1,6 +1,7 @@ var Game = { create: function() { + this.mode = "release"; // "test"; this.initVariables(); this.dbConnectManager = new DBConnectManager(); @@ -48,8 +49,6 @@ var Game = { }, initVariables: function() { - this.mode = "test"; - this.nextNumber = 1; this.difficulty = Chocoball.MODE_DIFFICULT; @@ -66,8 +65,16 @@ var Game = { }, drawObjects: function() { + var graphics = game.add.graphics(0, 0); + var outLineRadius = 97; + this.chocoballs = new Array(); for(var i = 0; i < 25; i++) { + graphics.lineStyle(0); + graphics.beginFill(0x202020); + graphics.drawCircle(Chocoball.getX(i), Chocoball.getY(i), outLineRadius); + graphics.endFill(); + var chocoball = new Chocoball( i, this.difficulty, @@ -77,7 +84,6 @@ var Game = { this.chocoballs.push(chocoball); } - var graphics = game.add.graphics(0, 0); var triangleStartX = God.POSITION_X; var triangleStartY = God.POSITION_Y - 245; var triangleHalfWidth = 20; @@ -132,37 +138,34 @@ var Game = { onClickChocoball: function(chocoball) { // console.log(chocoball.index); // console.log(chocoball.number); - - if(chocoball.number == 1) - this.stopWatch.start(); - - if(chocoball.number == this.nextNumber) { - this.nextNumber++; - this.god.animateHappy(); - } else { + if(chocoball.number == 50) { + // console.log("game clear"); + chocoball.setVisible(false); + this.gameClear(); + return; + } + if(chocoball.number != this.nextNumber) { console.log("wrong"); this.god.animateAngry(); return; } - if(chocoball.number < 25) { + // clicked correct number + if(chocoball.number == 1) + this.stopWatch.start(); + + this.nextNumber++; + this.god.animateHappy(); + + if(chocoball.number <= 25) chocoball.setNumber(this.secondChocoballArray[chocoball.index]); - this.nextChocoball.setNumber(this.nextNumber); - } else { + else chocoball.setVisible(false); - } + this.nextChocoball.setNumber(this.nextNumber); - if(this.mode == "test") { - if(this.nextNumber == 3) { - console.log("time over"); - this.timeOver(); - } - return; - } - - if(chocoball.number == 50) { - console.log("game clear"); - this.gameClear(); + if(this.mode == "test" && this.nextNumber == 3) { + console.log("time over"); + this.timeOver(); } },