From 208b87eda68caa6a465c4f4da5f6ba9b684d0d3a Mon Sep 17 00:00:00 2001 From: Theunis Johannes Botha Date: Thu, 24 May 2018 17:42:25 +0200 Subject: [PATCH 1/4] Update: CC - Entity Loaded - AR Football 3 (ff0fsum4zx.js) 11 bytes modified --- ff0fsum4zx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ff0fsum4zx.js b/ff0fsum4zx.js index 1f1924b..b29a144 100644 --- a/ff0fsum4zx.js +++ b/ff0fsum4zx.js @@ -410,7 +410,7 @@ R3.Event.Subscribe( this.mouseMove.entityLoaded = this; this.touchMove.entityLoaded = this; this.beforeRender.entityLoaded = this; - } + }.bind(this) ); R3.Event.Emit(R3.Event.GAME_LOADED); From 3d8b1a3033268b56d24d50ce89abab2b29a8a355 Mon Sep 17 00:00:00 2001 From: Theunis Johannes Botha Date: Fri, 25 May 2018 08:46:47 +0200 Subject: [PATCH 2/4] Update: CC - Entity Loaded - AR Football 3 (ff0fsum4zx.js) 229 bytes modified --- ff0fsum4zx.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ff0fsum4zx.js b/ff0fsum4zx.js index b29a144..36624fc 100644 --- a/ff0fsum4zx.js +++ b/ff0fsum4zx.js @@ -136,6 +136,13 @@ R3.CustomCode.prototype.render = function(delta) { name : 'Audio - Crowd Cheer' } ); + R3.Event.Emit( + R3.Event.GAME_DATA, + { + type : 'score', + goal : 'left' + } + ); } } @@ -150,6 +157,13 @@ R3.CustomCode.prototype.render = function(delta) { name : 'Audio - Crowd Cheer' } ); + R3.Event.Emit( + R3.Event.GAME_DATA, + { + type : 'score', + goal : 'right' + } + ); } } From b8ff03924dfeb7bea4b6568c2c8861ff1250cfc7 Mon Sep 17 00:00:00 2001 From: Theunis Johannes Botha Date: Fri, 25 May 2018 12:18:01 +0200 Subject: [PATCH 3/4] Update: CC - Entity Loaded - AR Football 3 (ff0fsum4zx.js) 2985 bytes modified --- ff0fsum4zx.js | 134 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 129 insertions(+), 5 deletions(-) diff --git a/ff0fsum4zx.js b/ff0fsum4zx.js index 36624fc..2fd2cf5 100644 --- a/ff0fsum4zx.js +++ b/ff0fsum4zx.js @@ -41,6 +41,8 @@ this.playerRotation = { y : 0 }; +R3.CustomCode.TIME_LIMIT = 1.5 * 60; + this.balls = []; this.activeBall = this.football.instance; @@ -69,6 +71,12 @@ this.endRayZ = -2.5; this.playerY = 0.389; +this.totalTime = R3.CustomCode.TIME_LIMIT; + +this.score = 0; + +this.secondCounter = 0; + this.ballY = this.football.instance.geometry.boundingSphere.radius / 2; if (this.debug) { @@ -82,6 +90,45 @@ if (this.debug) { R3.CustomCode.prototype.render = function(delta) { + this.totalTime -= delta; + + this.secondCounter += delta; + if (this.secondCounter >= 1) { + this.secondCounter -= 1; + R3.Event.Emit( + R3.Event.GAME_DATA, + { + type : 'timer', + time : Math.round(this.totalTime) + } + ) + } + + if (this.totalTime <= 0) { + + this.totalTime = 0; + + R3.Event.Emit( + R3.Event.GAME_OVER, + { + timeLimit : R3.CustomCode.TIME_LIMIT, + timeUsed : R3.CustomCode.TIME_LIMIT - this.totalTime, + score : this.score, + goals : this.balls.reduce( + function(result, ball){ + if (ball.scored) { + result.push(ball); + } + return result; + }, + [] + ) + } + ) + } + + if (this.totalTime) + this.balls.map( function(ball) { @@ -400,20 +447,96 @@ R3.CustomCode.prototype.move = function(data) { this.activeBall = null; } - - - }.bind(this) -this.footballPlayer.instance.translateY(this.playerY); -this.football.instance.position.y = this.ballY; +R3.Event.Subscribe( + R3.Event.GAME_OVER, + function(data) { + + R3.Event.Emit( + R3.Event.PLAY_AUDIO, + { + name : 'Audio - Crowd Cheer' + } + ); + + R3.Event.Emit( + R3.Event.STOP_AUDIO, + { + name : 'Audio - Crowd' + } + ); + + this.mouseMove.entityLoaded = null; + this.touchMove.entityLoaded = null; + this.beforeRender.entityLoaded = null; + + }.bind(this) +); R3.Event.Subscribe( R3.Event.GAME_START, function() { + /** + * Reset football player + * @type {number} + */ + this.footballPlayer.instance.rotation.x = 0; + this.footballPlayer.instance.rotation.y = 0; + this.footballPlayer.instance.rotation.z = 0; + + this.footballPlayer.instance.position.x = 0; + this.footballPlayer.instance.position.y = 0; + this.footballPlayer.instance.position.z = 0; + + this.footballPlayer.instance.position.y = this.playerY; + + /** + * Reset football + * @type {number} + */ + this.football.instance.rotation.x = 0; + this.football.instance.rotation.y = 0; + this.football.instance.rotation.z = 0; + + this.football.instance.position.x = 0; + this.football.instance.position.y = 0; + this.football.instance.position.z = 0; + + this.football.instance.position.y = this.ballY; + + this.score = 0; + + this.secondCounter = 0; + + this.totalTime = R3.CustomCode.TIME_LIMIT; + + R3.Event.Emit( + R3.Event.GAME_DATA, + { + type : 'timer', + time : this.totalTime + } + ); + + this.balls.map( + function(ball) { + + this.football.parentScene.instance.remove(ball.mesh); + + ball.mesh.material = null; + ball.mesh.geometry = null; + delete ball.mesh; + ball.mesh = null; + + }.bind(this) + ); + + this.balls = []; + R3.Event.Emit( R3.Event.PLAY_AUDIO, { @@ -424,6 +547,7 @@ R3.Event.Subscribe( this.mouseMove.entityLoaded = this; this.touchMove.entityLoaded = this; this.beforeRender.entityLoaded = this; + }.bind(this) ); From b6b421f46d8a4aa34e505be73b2ea8549b317446 Mon Sep 17 00:00:00 2001 From: Theunis Johannes Botha Date: Fri, 25 May 2018 13:16:01 +0200 Subject: [PATCH 4/4] Update: CC - Entity Loaded - AR Football 3 (ff0fsum4zx.js) 43 bytes modified --- ff0fsum4zx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ff0fsum4zx.js b/ff0fsum4zx.js index 2fd2cf5..94d2ab3 100644 --- a/ff0fsum4zx.js +++ b/ff0fsum4zx.js @@ -377,7 +377,7 @@ R3.CustomCode.prototype.move = function(data) { this.footballPlayer.instance.rotateY(this.playerRotation.x); - this.footballPlayer.instance.translateZ(this.ballY); + this.footballPlayer.instance.translateZ(this.football.instance.geometry.boundingSphere.radius); this.footballPlayer.instance.rotateX(this.playerRotation.y);