code
parent
2fdc7af240
commit
61860f0076
|
@ -1,2 +1,34 @@
|
||||||
return null;
|
if (!this.entityLoaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.keyCode === R3.System.Input.KEY_UP) {
|
||||||
|
R3.Event.Emit(
|
||||||
|
R3.Event.GAME_DATA,
|
||||||
|
{
|
||||||
|
type : 'shoot'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.keyCode === R3.System.Input.KEY_LEFT) {
|
||||||
|
R3.Event.Emit(
|
||||||
|
R3.Event.GAME_DATA,
|
||||||
|
{
|
||||||
|
type : 'left'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.keyCode === R3.System.Input.KEY_RIGHT) {
|
||||||
|
R3.Event.Emit(
|
||||||
|
R3.Event.GAME_DATA,
|
||||||
|
{
|
||||||
|
type : 'right'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//@ sourceURL=keyDown.js
|
//@ sourceURL=keyDown.js
|
|
@ -1,3 +1,5 @@
|
||||||
|
return;
|
||||||
|
|
||||||
if (!this.entityLoaded) {
|
if (!this.entityLoaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
184
ff0fsum4zx.js
184
ff0fsum4zx.js
|
@ -85,7 +85,9 @@ this.invertY = true;
|
||||||
|
|
||||||
this.invertX = true;
|
this.invertX = true;
|
||||||
|
|
||||||
this.shooting = false;
|
this.preparing = false;
|
||||||
|
|
||||||
|
this.looking = null;
|
||||||
|
|
||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
this.arrowHelper = new THREE.ArrowHelper(
|
this.arrowHelper = new THREE.ArrowHelper(
|
||||||
|
@ -124,19 +126,44 @@ R3.CustomCode.prototype.render = function(delta) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.shooting === true) {
|
if (this.preparing === true) {
|
||||||
|
|
||||||
this.move(
|
this.move(
|
||||||
{
|
{
|
||||||
x : 0,
|
x : 0,
|
||||||
y : 10 * delta
|
y : delta * -200
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.playerRotation.y < 0) {
|
if (this.preparing === false && this.playerRotation.y < 0) {
|
||||||
this.playerRotation.y = 0;
|
this.move(
|
||||||
this.shooting = false;
|
{
|
||||||
}
|
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) {
|
if (this.totalTime <= 0) {
|
||||||
|
@ -328,7 +355,7 @@ R3.CustomCode.prototype.render = function(delta) {
|
||||||
R3.CustomCode.prototype.move = function(data) {
|
R3.CustomCode.prototype.move = function(data) {
|
||||||
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
|
|
||||||
if (data && data.x) {
|
if (data && data.x) {
|
||||||
if (this.invertX) {
|
if (this.invertX) {
|
||||||
x = data.x;
|
x = data.x;
|
||||||
|
@ -336,22 +363,22 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
x = -data.x;
|
x = -data.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var y = 0;
|
var y = 0;
|
||||||
|
|
||||||
if (data && data.y) {
|
if (data && data.y) {
|
||||||
|
|
||||||
if (this.invertY) {
|
if (this.invertY) {
|
||||||
y = data.y;
|
y = data.y;
|
||||||
} else {
|
} else {
|
||||||
y = -data.y;
|
y = -data.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
x *= 0.0025;
|
x *= 0.0025;
|
||||||
y *= 0.0075;
|
y *= 0.0075;
|
||||||
|
|
||||||
|
|
||||||
this.playerRotation.x += x;
|
this.playerRotation.x += x;
|
||||||
this.playerRotation.y += y;
|
this.playerRotation.y += y;
|
||||||
|
@ -359,8 +386,9 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
/**
|
/**
|
||||||
* Clamp player rotation to values between 0 and Math.PI * 2
|
* 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 = Math.PI;
|
this.playerRotation.y = 0;
|
||||||
|
this.kick = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.playerRotation.y < -Math.PI) {
|
if (this.playerRotation.y < -Math.PI) {
|
||||||
|
@ -375,41 +403,39 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
this.playerRotation.x = -Math.PI / 2;
|
this.playerRotation.x = -Math.PI / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.playerRotation.y <= 0) {
|
// if (this.playerRotation.y <= 0) {
|
||||||
this.canKick = true;
|
// this.canKick = true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (this.canKick && this.playerRotation.y > 0) {
|
//if (this.canKick && this.playerRotation.y === 0) {
|
||||||
this.canKick = false;
|
// this.canKick = false;
|
||||||
this.kick = true;
|
// 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 = new THREE.Matrix4();
|
||||||
this.footballPlayer.instance.matrix.decompose(
|
this.footballPlayer.instance.matrix.decompose(
|
||||||
|
@ -430,10 +456,12 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
|
|
||||||
this.kick = false;
|
this.kick = false;
|
||||||
|
|
||||||
if (this.startTime === null) {
|
//this.shooting = false;
|
||||||
console.warn('no kick start time');
|
|
||||||
return;
|
// if (this.startTime === null) {
|
||||||
}
|
// console.warn('no kick start time');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
R3.Event.Emit(
|
R3.Event.Emit(
|
||||||
R3.Event.PLAY_AUDIO,
|
R3.Event.PLAY_AUDIO,
|
||||||
|
@ -442,9 +470,11 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var kickDuration = Date.now() - this.startTime;
|
//var kickDuration = 1;//Date.now() - this.startTime;
|
||||||
|
|
||||||
var speed = this.kickDistance / kickDuration * 20;
|
var speed = this.kickDistance;
|
||||||
|
|
||||||
|
console.log('speed = ' + speed);
|
||||||
|
|
||||||
// if (speed > 1.5) {
|
// if (speed > 1.5) {
|
||||||
// speed = 1.5;
|
// speed = 1.5;
|
||||||
|
@ -476,7 +506,7 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
kickDuration : this.kickDuration,
|
kickDuration : this.kickDuration,
|
||||||
kickDistance : this.kickDistance,
|
kickDistance : this.kickDistance,
|
||||||
kickSpeed : speed,
|
kickSpeed : speed,
|
||||||
upAngle : Math.PI * speed,
|
upAngle : speed,
|
||||||
v : v,
|
v : v,
|
||||||
vRotationAxis : vRotationAxis,
|
vRotationAxis : vRotationAxis,
|
||||||
t : 0,
|
t : 0,
|
||||||
|
@ -492,7 +522,7 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
this.activeBall = null;
|
this.activeBall = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this);
|
||||||
|
|
||||||
|
|
||||||
R3.Event.Subscribe(
|
R3.Event.Subscribe(
|
||||||
|
@ -527,40 +557,28 @@ R3.Event.Subscribe(
|
||||||
function(data) {
|
function(data) {
|
||||||
|
|
||||||
if (data.type === 'shoot') {
|
if (data.type === 'shoot') {
|
||||||
|
this.preparing = true;
|
||||||
console.log('shoot');
|
|
||||||
|
|
||||||
this.shooting = false;
|
|
||||||
|
|
||||||
this.move(
|
|
||||||
{
|
|
||||||
x : 0,
|
|
||||||
y : -10
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.type === 'shoot_release') {
|
if (data.type === 'shoot_release') {
|
||||||
console.log('shoot release');
|
this.preparing = false;
|
||||||
this.shooting = true;
|
this.kickDistance = Math.abs(this.playerRotation.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.type === 'look_left') {
|
if (data.type === 'left') {
|
||||||
this.move(
|
this.looking = 'left';
|
||||||
{
|
|
||||||
x : -10,
|
|
||||||
y : 0
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.type === 'look_right') {
|
if (data.type === 'right') {
|
||||||
this.move(
|
this.looking = 'right';
|
||||||
{
|
}
|
||||||
x : 10,
|
|
||||||
y : 0
|
if (data.type === 'right_release') {
|
||||||
}
|
this.looking = null;
|
||||||
);
|
}
|
||||||
|
|
||||||
|
if (data.type === 'left_release') {
|
||||||
|
this.looking = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
return;
|
||||||
|
|
||||||
if (!this.entityLoaded) {
|
if (!this.entityLoaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,31 @@ if (!this.entityLoaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(data);
|
if (data.keyCode === R3.System.Input.KEY_LEFT) {
|
||||||
|
R3.Event.Emit(
|
||||||
|
R3.Event.GAME_DATA,
|
||||||
|
{
|
||||||
|
type : 'left_release'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
//@ sourceURL=keyDown.js
|
if (data.keyCode === R3.System.Input.KEY_RIGHT) {
|
||||||
|
R3.Event.Emit(
|
||||||
|
R3.Event.GAME_DATA,
|
||||||
|
{
|
||||||
|
type : 'right_release'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.keyCode === R3.System.Input.KEY_UP) {
|
||||||
|
R3.Event.Emit(
|
||||||
|
R3.Event.GAME_DATA,
|
||||||
|
{
|
||||||
|
type : 'shoot_release'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
//@ sourceURL=keyUp.js
|
Loading…
Reference in New Issue