Add: HintBubble

Fix: chocoball color
Fix: history, ranking DB
This commit is contained in:
2019-05-11 16:14:17 +09:00
parent a02e75e06a
commit edb8b43020
10 changed files with 145 additions and 86 deletions
+7 -8
View File
@@ -69,7 +69,7 @@ Chocoball.prototype.setBodyColor = function(number) {
else if(number < 41) else if(number < 41)
this.body.tint = Chocoball.COLOR_31_TO_40; this.body.tint = Chocoball.COLOR_31_TO_40;
else else
this.body.tint = Chocoball.COLOR_41_TO_50; this.body.tint = Chocoball.COLOR_BLACK;
} }
@@ -91,14 +91,14 @@ Chocoball.prototype.onClick = function() {
Chocoball.getX = function(index) { Chocoball.getX = function(index) {
if(index == 100) if(index == 100)
return 840; return 0;
return 250 + (index % 5) * 70; return 250 + (index % 5) * 70;
} }
Chocoball.getY = function(index) { Chocoball.getY = function(index) {
if(index == 100) if(index == 100)
return 285; return 0;
return 250 + (Math.floor(index / 5)) * 70; return 250 + (Math.floor(index / 5)) * 70;
} }
@@ -131,11 +131,10 @@ Chocoball.DEFAULT_STROKE_WIDTH_PX = 5; // in pixel
Chocoball.RADIUS = 90; Chocoball.RADIUS = 90;
Chocoball.COLOR_BLACK = 0x553333; Chocoball.COLOR_BLACK = 0x553333;
Chocoball.COLOR_1_TO_10 = 0x0090ff; // blue Chocoball.COLOR_1_TO_10 = 0x3090FF; // blue
Chocoball.COLOR_11_TO_20 = 0xff2000; // red Chocoball.COLOR_11_TO_20 = 0xD02000; // red
Chocoball.COLOR_21_TO_30 = 0x00ff30; // green Chocoball.COLOR_21_TO_30 = 0xFFFF00; // yellow
Chocoball.COLOR_31_TO_40 = 0xffff33; // yellow Chocoball.COLOR_31_TO_40 = 0x00FF00; // green
Chocoball.COLOR_41_TO_50 = 0x33ffff; //
Chocoball.MODE_EASY = 0; Chocoball.MODE_EASY = 0;
Chocoball.MODE_DIFFICULT = 1; Chocoball.MODE_DIFFICULT = 1;
+4 -26
View File
@@ -57,7 +57,7 @@ var Game = {
// if previous record is over 60 sec, play easy mode // if previous record is over 60 sec, play easy mode
var prevRecord = sessionStorageManager.getRecord() var prevRecord = sessionStorageManager.getRecord()
// console.log(prevRecord); // console.log(prevRecord);
var secForEasyMode = this.mode == "test" ? 1 : 60; var secForEasyMode = this.mode == "test" ? 1 : 40;
if(prevRecord > secForEasyMode) { if(prevRecord > secForEasyMode) {
this.difficulty = Chocoball.MODE_EASY; this.difficulty = Chocoball.MODE_EASY;
} }
@@ -86,37 +86,14 @@ var Game = {
this.chocoballs.push(chocoball); this.chocoballs.push(chocoball);
} }
var triangleStartX = God.POSITION_X; this.hintBubble = new HintBubble(God.POSITION_X, God.POSITION_Y - 260);
var triangleStartY = God.POSITION_Y - 245;
var triangleHalfWidth = 20;
var triangleHeight = 40;
graphics.beginFill(0xFFFFFF);
graphics.lineStyle(20, 0x000000);
graphics.moveTo(triangleStartX, triangleStartY);
graphics.lineTo(triangleStartX + triangleHalfWidth, triangleStartY - triangleHeight);
graphics.lineTo(triangleStartX - triangleHalfWidth, triangleStartY - triangleHeight);
graphics.lineTo(triangleStartX, triangleStartY);
graphics.endFill();
graphics.lineStyle(10, 0x000000);
graphics.beginFill(0xFFFFFF);
graphics.drawCircle(God.POSITION_X, God.POSITION_Y - 360, 200);
graphics.endFill();
graphics.beginFill(0xFFFFFF);
graphics.lineStyle(0);
graphics.moveTo(triangleStartX, triangleStartY);
graphics.lineTo(triangleStartX + triangleHalfWidth, triangleStartY - triangleHeight);
graphics.lineTo(triangleStartX - triangleHalfWidth, triangleStartY - triangleHeight);
graphics.lineTo(triangleStartX, triangleStartY);
graphics.endFill();
this.nextChocoball = new Chocoball( this.nextChocoball = new Chocoball(
100, 100,
this.difficulty, this.difficulty,
(function(chocoball) { console.log("no event") }).bind(this) (function(chocoball) { console.log("no event") }).bind(this)
); );
this.nextChocoball.setNumber(this.nextNumber); this.nextChocoball.setNumber(this.nextNumber);
this.hintBubble.addChild(this.nextChocoball.body);
this.god = new God(God.POSITION_X, God.POSITION_Y, this); this.god = new God(God.POSITION_X, God.POSITION_Y, this);
}, },
@@ -165,6 +142,7 @@ var Game = {
else else
chocoball.setVisible(false); chocoball.setVisible(false);
this.nextChocoball.setNumber(this.nextNumber); this.nextChocoball.setNumber(this.nextNumber);
this.hintBubble.animateNextHint();
if(this.mode == "test" && this.nextNumber == 3) { if(this.mode == "test" && this.nextNumber == 3) {
console.log("time over"); console.log("time over");
+6 -14
View File
@@ -41,28 +41,20 @@ God.prototype.setScale = function(size) {
} }
God.prototype.animateHappy = function(type) { God.prototype.animateHappy = function() {
this.loadTexture('god_happy'); this.loadTexture('god_happy');
// this.mainGame.speechBubble.showSpeechBubble(type);
var tween = game.add.tween(this.scale); var tween = game.add.tween(this.scale);
tween.to({x:0.6, y:0.6}, 500, Phaser.Easing.Quadratic.Out, true, 0); tween.to({y:0.52}, 500, Phaser.Easing.Quadratic.Out, true, 0);
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true);
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Linear.None, true, 0);
tween.onComplete.add(this.smileAgain, this); tween.onComplete.add(this.smileAgain, this);
tween.start(); tween.start();
} }
God.prototype.animateAngry = function(type) { God.prototype.animateAngry = function() {
this.loadTexture('god_angry'); this.loadTexture('god_angry');
// this.mainGame.speechBubble.showSpeechBubble(type);
var tween = game.add.tween(this.scale); var tween = game.add.tween(this.scale);
// tween.to({x:0.7}, 1000, Phaser.Easing.Quadratic.In, true, 0); tween.to({x:0.55}, 500, Phaser.Easing.Bounce.Out, true, 0);
tween.to({x:0.6}, 1000, Phaser.Easing.Bounce.Out, true, 0);
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true);
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Linear.None, true, 0);
tween.onComplete.add(this.smileAgain, this); tween.onComplete.add(this.smileAgain, this);
tween.start(); tween.start();
} }
@@ -80,5 +72,5 @@ God.loadResources = function() {
} }
God.POSITION_X = 840; God.POSITION_X = 800;
God.POSITION_Y = 645; God.POSITION_Y = 560;
@@ -0,0 +1,76 @@
function HintBubble(x, y) {
this.posY = y;
this.bubble = this.makeBubbleSprite(x, y);
}
HintBubble.prototype.makeBubbleSprite = function(x, y) {
var graphics = new Phaser.Graphics(game, 0, 0);
var triangleStartX = 0;
var triangleStartY = HintBubble.RADIUS / 7 * 4;
var triangleHalfWidth = HintBubble.TRIANGLE_WIDTH / 2;
// tail outline
graphics.lineStyle(HintBubble.STROKE_WIDTH, HintBubble.COLOR_BUBBLE_STROKE);
graphics.beginFill(HintBubble.COLOR_BUBBLE_FILL);
graphics.moveTo(triangleStartX, triangleStartY);
graphics.lineTo(triangleStartX + triangleHalfWidth, triangleStartY - HintBubble.TRIANGLE_HEIGHT);
graphics.lineTo(triangleStartX - triangleHalfWidth, triangleStartY - HintBubble.TRIANGLE_HEIGHT);
graphics.lineTo(triangleStartX, triangleStartY);
graphics.endFill();
// circle
graphics.lineStyle(HintBubble.STROKE_WIDTH / 2, HintBubble.COLOR_BUBBLE_STROKE);
graphics.beginFill(HintBubble.COLOR_BUBBLE_FILL);
graphics.drawCircle(0, 0, HintBubble.RADIUS);
graphics.endFill();
// tail body
graphics.lineStyle(0);
graphics.beginFill(HintBubble.COLOR_BUBBLE_FILL);
graphics.moveTo(triangleStartX, triangleStartY);
graphics.lineTo(triangleStartX + triangleHalfWidth, triangleStartY - HintBubble.TRIANGLE_HEIGHT);
graphics.lineTo(triangleStartX - triangleHalfWidth, triangleStartY - HintBubble.TRIANGLE_HEIGHT);
graphics.lineTo(triangleStartX, triangleStartY);
graphics.endFill();
texture = graphics.generateTexture();
sprite = game.add.sprite(x, y, texture);
sprite.anchor.set(0.5);
return sprite;
}
HintBubble.prototype.addChild = function(chocoball) {
this.bubble.addChild(chocoball);
chocoball.y -= HintBubble.TRIANGLE_HEIGHT / 9 * 2;
}
HintBubble.prototype.animateNextHint = function() {
this.bubble.y = this.posY + HintBubble.ANIMATION_HEIGHT;
var tween = game.add.tween(this.bubble);
tween.to({y:this.posY}, 500, Phaser.Easing.Quadratic.Out, true, 0);
tween.onComplete.add(this.animateReset, this);
tween.start();
}
HintBubble.prototype.animateReset = function() {
this.bubble.y = this.posY;
}
HintBubble.RADIUS = 110;
HintBubble.TRIANGLE_HEIGHT = 40;
HintBubble.TRIANGLE_WIDTH = 40;
HintBubble.STROKE_WIDTH = 10;
HintBubble.OFFSET_Y = 240;
HintBubble.ANIMATION_HEIGHT = 20;
HintBubble.COLOR_BUBBLE_FILL = 0xFFEEEE;
HintBubble.COLOR_BUBBLE_STROKE = 0x331122;
+1
View File
@@ -69,6 +69,7 @@
<script src="../../game/mouse/one_to_fifty/stop_watch.js"></script> <script src="../../game/mouse/one_to_fifty/stop_watch.js"></script>
<script src="../../game/mouse/one_to_fifty/chocoball.js"></script> <script src="../../game/mouse/one_to_fifty/chocoball.js"></script>
<script src="../../game/mouse/one_to_fifty/god.js"></script> <script src="../../game/mouse/one_to_fifty/god.js"></script>
<script src="../../game/mouse/one_to_fifty/hint_bubble.js"></script>
<script src="../../game/mouse/one_to_fifty/game.js"></script> <script src="../../game/mouse/one_to_fifty/game.js"></script>
<script src="../../game/mouse/one_to_fifty/main.js"></script> <script src="../../game/mouse/one_to_fifty/main.js"></script>
+21 -18
View File
@@ -24,16 +24,17 @@ function get_ranking_hour($maestroID, $appID) {
global $db_conn; global $db_conn;
$query = " $query = "
SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord
FROM best_record BR, player P FROM best_record BR, player P
WHERE BR.PlayerID = P.PlayerID AND DATE(BR.RecordDateTime) = DATE(NOW()) AND HOUR(BR.RecordDateTime) = HOUR(NOW()) AND BR.MaestroID = ? AND BR.AppID = ? WHERE BR.PlayerID = P.PlayerID AND DATE(BR.RecordDateTime) = DATE(NOW()) AND HOUR(BR.RecordDateTime) = HOUR(NOW()) AND BR.MaestroID = ? AND BR.AppID = ?
GROUP BY BR.PlayerID GROUP BY BR.PlayerID
ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($appID)) if(is_highest_record_prefer_app($appID)) {
$query = $query." DESC;"; $query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord".$query;
else $query = $query."ORDER BY max(BR.BestRecord) DESC;";
$query = $query." ASC;"; } else {
$query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MIN(BR.BestRecord) AS BestRecord".$query;
$query = $query."ORDER BY min(BR.BestRecord) ASC;";
}
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $appID); $stmt->bind_param('ii', $maestroID, $appID);
$stmt->execute(); $stmt->execute();
@@ -53,16 +54,17 @@ function get_ranking_day($maestroID, $appID) {
global $db_conn; global $db_conn;
$query = " $query = "
SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord
FROM best_record BR, player P FROM best_record BR, player P
WHERE BR.PlayerID = P.PlayerID AND DATE(BR.RecordDateTime) = DATE(NOW()) AND BR.MaestroID = ? AND BR.AppID = ? WHERE BR.PlayerID = P.PlayerID AND DATE(BR.RecordDateTime) = DATE(NOW()) AND BR.MaestroID = ? AND BR.AppID = ?
GROUP BY BR.PlayerID GROUP BY BR.PlayerID
ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($appID)) if(is_highest_record_prefer_app($appID)) {
$query = $query." DESC;"; $query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord".$query;
else $query = $query."ORDER BY max(BR.BestRecord) DESC;";
$query = $query." ASC;"; } else {
$query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MIN(BR.BestRecord) AS BestRecord".$query;
$query = $query."ORDER BY min(BR.BestRecord) ASC;";
}
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $appID); $stmt->bind_param('ii', $maestroID, $appID);
$stmt->execute(); $stmt->execute();
@@ -82,16 +84,17 @@ function get_ranking_month($maestroID, $appID) {
global $db_conn; global $db_conn;
$query = " $query = "
SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord
FROM best_record BR, player P FROM best_record BR, player P
WHERE BR.PlayerID = P.PlayerID AND MONTH(BR.RecordDateTime) = MONTH(NOW()) AND BR.MaestroID = ? AND BR.AppID = ? WHERE BR.PlayerID = P.PlayerID AND MONTH(BR.RecordDateTime) = MONTH(NOW()) AND BR.MaestroID = ? AND BR.AppID = ?
GROUP BY BR.PlayerID GROUP BY BR.PlayerID
ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($appID)) if(is_highest_record_prefer_app($appID)) {
$query = $query." DESC;"; $query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord".$query;
else $query = $query."ORDER BY max(BR.BestRecord) DESC;";
$query = $query." ASC;"; } else {
$query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MIN(BR.BestRecord) AS BestRecord".$query;
$query = $query."ORDER BY min(BR.BestRecord) ASC;";
}
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $appID); $stmt->bind_param('ii', $maestroID, $appID);
$stmt->execute(); $stmt->execute();
+7 -1
View File
@@ -7,6 +7,7 @@ $player_id = $_POST["PlayerID"];
$date = $_POST["Date"]; $date = $_POST["Date"];
include "./../setup/connect_db.php"; include "./../setup/connect_db.php";
include "./../lib/util_app.php";
$replyJSON = get_history_record($maestro_id, $app_id, $player_id, $date); $replyJSON = get_history_record($maestro_id, $app_id, $player_id, $date);
@@ -24,7 +25,6 @@ function get_history_record($maestro_id, $app_id, $player_id, $date) {
global $db_conn; global $db_conn;
$query = " $query = "
SELECT DATE(BR.RecordDateTime) AS Date, MAX(BR.BestRecord) AS HighScore, AA.AppName AS AppName
FROM best_record BR FROM best_record BR
INNER JOIN app AS AA INNER JOIN app AS AA
ON BR.MaestroID = ? AND BR.PlayerID = ? AND DATE(BR.RecordDateTime) <= ? AND BR.AppID = ? AND BR.AppID = AA.AppID ON BR.MaestroID = ? AND BR.PlayerID = ? AND DATE(BR.RecordDateTime) <= ? AND BR.AppID = ? AND BR.AppID = AA.AppID
@@ -32,6 +32,12 @@ function get_history_record($maestro_id, $app_id, $player_id, $date) {
ORDER BY BR.RecordDateTime DESC ORDER BY BR.RecordDateTime DESC
LIMIT 7 LIMIT 7
"; ";
if(is_highest_record_prefer_app($app_id)) {
$query = "SELECT DATE(BR.RecordDateTime) AS Date, MAX(BR.BestRecord) AS HighScore, AA.AppName AS AppName".$query;
}
else {
$query = "SELECT DATE(BR.RecordDateTime) AS Date, MIN(BR.BestRecord) AS HighScore, AA.AppName AS AppName".$query;
}
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('iisi', $maestro_id, $player_id, $date, $app_id); $stmt->bind_param('iisi', $maestro_id, $player_id, $date, $app_id);
$stmt->execute(); $stmt->execute();
+7 -6
View File
@@ -25,16 +25,17 @@ function get_ranking_record_day($maestro_id, $date, $app_id) {
global $db_conn; global $db_conn;
$query = " $query = "
SELECT BR.playerID As PlayerID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
FROM best_record BR, player U FROM best_record BR, player U
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND AppID = ? WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND AppID = ?
GROUP BY BR.playerID GROUP BY BR.playerID
ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($app_id)) if(is_highest_record_prefer_app($app_id)) {
$query = $query." DESC;"; $query = "SELECT BR.playerID As PlayerID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore".$query;
else $query = $query."ORDER BY MAX(BR.BestRecord) DESC;";
$query = $query." ASC;"; } else {
$query = "SELECT BR.playerID As PlayerID, U.Name AS Name, MIN(BR.BestRecord) AS HighScore".$query;
$query = $query."ORDER BY MIN(BR.BestRecord) ASC;";
}
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('isi', $maestro_id, $date, $app_id); $stmt->bind_param('isi', $maestro_id, $date, $app_id);
$stmt->execute(); $stmt->execute();
@@ -20,20 +20,22 @@ if($replyJSON.length === 0) {
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE); echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close(); $db_conn->close();
function get_ranking_record_hour($maestro_id, $date, $time, $app_id) { function get_ranking_record_hour($maestro_id, $date, $time, $app_id) {
global $db_conn; global $db_conn;
$query = " $query = "
SELECT BR.playerID As PlayerID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
FROM best_record BR, player U FROM best_record BR, player U
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ? WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND DATE(BR.RecordDateTime) = ? AND HOUR(BR.RecordDateTime) = HOUR(?) AND AppID = ?
GROUP BY BR.playerID GROUP BY BR.playerID
ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($app_id)) if(is_highest_record_prefer_app($app_id)) {
$query = $query." DESC;"; $query = "SELECT BR.playerID As PlayerID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore".$query;
else $query = $query."ORDER BY MAX(BR.BestRecord) DESC;";
$query = $query." ASC;"; } else {
$query = "SELECT BR.playerID As PlayerID, U.Name AS Name, MIN(BR.BestRecord) AS HighScore".$query;
$query = $query."ORDER BY MIN(BR.BestRecord) ASC;";
}
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('issi', $maestro_id, $date, $time, $app_id); $stmt->bind_param('issi', $maestro_id, $date, $time, $app_id);
$stmt->execute(); $stmt->execute();
@@ -25,16 +25,17 @@ function get_ranking_record_month($maestro_id, $date, $time, $app_id) {
global $db_conn; global $db_conn;
$query = " $query = "
SELECT BR.playerID As PlayerID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore
FROM best_record BR, player U FROM best_record BR, player U
WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND MONTH(BR.RecordDateTime) = MONTH(?) AND AppID = ? WHERE BR.MaestroID = ? AND BR.playerID = U.playerID AND MONTH(BR.RecordDateTime) = MONTH(?) AND AppID = ?
GROUP BY BR.playerID GROUP BY BR.playerID
ORDER BY max(BR.BestRecord)
"; ";
if(is_highest_record_prefer_app($app_id)) if(is_highest_record_prefer_app($app_id)) {
$query = $query." DESC;"; $query = "SELECT BR.playerID As PlayerID, U.Name AS Name, MAX(BR.BestRecord) AS HighScore".$query;
else $query = $query."ORDER BY MAX(BR.BestRecord) DESC;";
$query = $query." ASC;"; } else {
$query = "SELECT BR.playerID As PlayerID, U.Name AS Name, MIN(BR.BestRecord) AS HighScore".$query;
$query = $query."ORDER BY MIN(BR.BestRecord) ASC;";
}
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param('isi', $maestro_id, $date, $app_id); $stmt->bind_param('isi', $maestro_id, $date, $app_id);
$stmt->execute(); $stmt->execute();