From 1a91ebe39df6d3ae824b8956de1ec51ff0ab5ae1 Mon Sep 17 00:00:00 2001 From: Theunis Johannes Botha Date: Mon, 28 May 2018 19:40:17 +0200 Subject: [PATCH] Update: CC - Entity Loaded - AR Football 3 (ff0fsum4zx.js) 449 bytes modified --- ff0fsum4zx.js | 156 +++++++++++++++++++++++++++----------------------- 1 file changed, 84 insertions(+), 72 deletions(-) diff --git a/ff0fsum4zx.js b/ff0fsum4zx.js index cc23228..46fca8d 100644 --- a/ff0fsum4zx.js +++ b/ff0fsum4zx.js @@ -85,7 +85,9 @@ this.invertY = true; this.invertX = true; -this.shooting = false; +this.preparing = false; + +this.looking = null; if (this.debug) { this.arrowHelper = new THREE.ArrowHelper( @@ -124,16 +126,44 @@ R3.CustomCode.prototype.render = function(delta) { } ); - if (this.shooting === true) { - + if (this.preparing === true) { this.move( - { x : 0, - y : 1000 * delta + y : delta * -200 } ); + } + if (this.preparing === false && this.playerRotation.y < 0) { + this.move( + { + x : 0, + y : delta * 1000 + } + ); + }; + + if (this.looking === 'left') { + this.move( + { + x : delta * -700, + y : 0 + } + ); + } + + if (this.looking === 'right') { + this.move( + { + x : delta * 700, + y : 0 + } + ); + } + + if (this.activeBall === null) { + this.createActiveBall(); } if (this.totalTime <= 0) { @@ -356,8 +386,9 @@ R3.CustomCode.prototype.move = function(data) { /** * Clamp player rotation to values between 0 and Math.PI * 2 */ - if (this.playerRotation.y > Math.PI) { + if (this.playerRotation.y > 0) { this.playerRotation.y = 0; + this.kick = true; } if (this.playerRotation.y < -Math.PI) { @@ -372,41 +403,39 @@ R3.CustomCode.prototype.move = function(data) { this.playerRotation.x = -Math.PI / 2; } - if (this.playerRotation.y <= 0) { - this.canKick = true; - } + // if (this.playerRotation.y <= 0) { + // this.canKick = true; + // } - if (this.canKick && this.playerRotation.y > 0) { - this.canKick = false; - this.kick = true; - } + //if (this.canKick && this.playerRotation.y === 0) { + // this.canKick = false; + // this.kick = true; + // } - if (y > 0 && this.canKick) { + // if (y > 0 && this.canKick) { + // + // /** + // * Moving down, initialize start time and record the distance travelled + // */ + // if (this.startTime === null) { + // this.startTime = Date.now(); + // } + // + // //this.kickDistance += Math.abs(y); + // + // } + + // if (y < 0) { + // /** + // * We are no longer moving down, also reset our Y distance counter + // * @type {boolean} + // */ + // //this.kickDistance = 0; + // this.startTime = null; + // } - /** - * Moving down, initialize start time and record the distance travelled - */ - if (this.startTime === null) { - this.startTime = Date.now(); - } - - //this.kickDistance += Math.abs(y); - - } - - if (y < 0) { - /** - * We are no longer moving down, also reset our Y distance counter - * @type {boolean} - */ - //this.kickDistance = 0; - this.startTime = null; - } - if (this.canKick && this.activeBall === null) { - this.createActiveBall(); - } this.footballPlayer.instance.matrix = new THREE.Matrix4(); this.footballPlayer.instance.matrix.decompose( @@ -427,12 +456,12 @@ R3.CustomCode.prototype.move = function(data) { this.kick = false; - this.shooting = false; + //this.shooting = false; - if (this.startTime === null) { - console.warn('no kick start time'); - return; - } + // if (this.startTime === null) { + // console.warn('no kick start time'); + // return; + // } R3.Event.Emit( R3.Event.PLAY_AUDIO, @@ -528,45 +557,28 @@ R3.Event.Subscribe( function(data) { if (data.type === 'shoot') { - - console.log('shoot'); - - this.shooting = false; - - this.move( - { - x : 0, - y : -10 - } - ); + this.preparing = true; } if (data.type === 'shoot_release') { - this.shooting = true; - - - + this.preparing = false; this.kickDistance = Math.abs(this.playerRotation.y); - - } - if (data.type === 'look_left') { - this.move( - { - x : -10, - y : 0 - } - ); + if (data.type === 'left') { + this.looking = 'left'; } - if (data.type === 'look_right') { - this.move( - { - x : 10, - y : 0 - } - ); + if (data.type === 'right') { + this.looking = 'right'; + } + + if (data.type === 'right_release') { + this.looking = null; + } + + if (data.type === 'left_release') { + this.looking = null; } }.bind(this)