mirror of
https://github.com/overte-org/overte.git
synced 2025-06-21 17:41:24 +02:00
transformer and tiltmaze ball
This commit is contained in:
parent
cb1f5e3e4f
commit
42792fdd92
2 changed files with 28 additions and 16 deletions
|
@ -146,7 +146,11 @@
|
||||||
delete littleVersionProps.localRotation;
|
delete littleVersionProps.localRotation;
|
||||||
delete littleVersionProps.naturalPosition;
|
delete littleVersionProps.naturalPosition;
|
||||||
// delete littleVersionProps.script;
|
// delete littleVersionProps.script;
|
||||||
|
littleVersionProps.gravity = {
|
||||||
|
x: 0,
|
||||||
|
y: -5,
|
||||||
|
z: 0
|
||||||
|
};
|
||||||
var userData = JSON.parse(littleVersionProps.userData);
|
var userData = JSON.parse(littleVersionProps.userData);
|
||||||
var basePosition = userData["hifiHomeTransformerKey"].basePosition;
|
var basePosition = userData["hifiHomeTransformerKey"].basePosition;
|
||||||
var baseRotation = userData["hifiHomeTransformerKey"].baseRotation;
|
var baseRotation = userData["hifiHomeTransformerKey"].baseRotation;
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
blue: 0
|
blue: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
var THROTTLE = false;
|
var THROTTLE = true;
|
||||||
var THROTTLE_RATE = 1000;
|
var THROTTLE_RATE = 1000;
|
||||||
var sinceLastUpdate = 0;
|
var sinceLastUpdate = 0;
|
||||||
|
|
||||||
|
@ -66,21 +66,26 @@
|
||||||
VICTORY_SOUND = SoundCache.getSound("http://hifi-content.s3.amazonaws.com/DomainContent/Home/tiltMaze/levelUp.wav");
|
VICTORY_SOUND = SoundCache.getSound("http://hifi-content.s3.amazonaws.com/DomainContent/Home/tiltMaze/levelUp.wav");
|
||||||
Script.update.connect(this.update);
|
Script.update.connect(this.update);
|
||||||
},
|
},
|
||||||
|
|
||||||
startNearGrab: function() {
|
startNearGrab: function() {
|
||||||
//check to make sure a ball is in range, otherwise create one
|
//check to make sure a ball is in range, otherwise create one
|
||||||
this.testBallDistance();
|
this.testBallDistance();
|
||||||
},
|
},
|
||||||
|
|
||||||
continueNearGrab: function() {
|
continueNearGrab: function() {
|
||||||
this.testWinDistance();
|
this.testWinDistance();
|
||||||
this.testBallDistance();
|
this.testBallDistance();
|
||||||
},
|
},
|
||||||
|
|
||||||
continueDistantGrab: function() {
|
continueDistantGrab: function() {
|
||||||
this.testBallDistance();
|
this.testBallDistance();
|
||||||
this.testWinDistance();
|
this.testWinDistance();
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseGrab: function() {
|
releaseGrab: function() {
|
||||||
this.testBallDistance();
|
this.testBallDistance();
|
||||||
},
|
},
|
||||||
|
|
||||||
getBallStartLocation: function() {
|
getBallStartLocation: function() {
|
||||||
var mazeProps = Entities.getEntityProperties(this.entityID);
|
var mazeProps = Entities.getEntityProperties(this.entityID);
|
||||||
var right = Quat.getRight(mazeProps.rotation);
|
var right = Quat.getRight(mazeProps.rotation);
|
||||||
|
@ -96,6 +101,7 @@
|
||||||
var location = Vec3.sum(mazeProps.position, finalOffset);
|
var location = Vec3.sum(mazeProps.position, finalOffset);
|
||||||
return location;
|
return location;
|
||||||
},
|
},
|
||||||
|
|
||||||
createBall: function() {
|
createBall: function() {
|
||||||
if (this.ballLocked === true) {
|
if (this.ballLocked === true) {
|
||||||
return;
|
return;
|
||||||
|
@ -127,6 +133,7 @@
|
||||||
|
|
||||||
this.ball = Entities.addEntity(properties);
|
this.ball = Entities.addEntity(properties);
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyBall: function() {
|
destroyBall: function() {
|
||||||
var results = Entities.findEntities(MyAvatar.position, 10);
|
var results = Entities.findEntities(MyAvatar.position, 10);
|
||||||
results.forEach(function(result) {
|
results.forEach(function(result) {
|
||||||
|
@ -137,6 +144,7 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
testBallDistance: function() {
|
testBallDistance: function() {
|
||||||
if (this.ballLocked === true) {
|
if (this.ballLocked === true) {
|
||||||
return;
|
return;
|
||||||
|
@ -166,12 +174,12 @@
|
||||||
var ballSpawnerPosition = Entities.getEntityProperties(data.tiltMaze.ballSpawner, 'position').position;
|
var ballSpawnerPosition = Entities.getEntityProperties(data.tiltMaze.ballSpawner, 'position').position;
|
||||||
|
|
||||||
var separation = Vec3.distance(ballPosition, ballSpawnerPosition);
|
var separation = Vec3.distance(ballPosition, ballSpawnerPosition);
|
||||||
print('ball separation: ' + separation)
|
|
||||||
if (separation > BALL_DISTANCE_THRESHOLD) {
|
if (separation > BALL_DISTANCE_THRESHOLD) {
|
||||||
this.destroyBall();
|
this.destroyBall();
|
||||||
this.createBall();
|
this.createBall();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
testWinDistance: function() {
|
testWinDistance: function() {
|
||||||
if (this.ballLocked === true) {
|
if (this.ballLocked === true) {
|
||||||
return;
|
return;
|
||||||
|
@ -209,6 +217,7 @@
|
||||||
}, 1500)
|
}, 1500)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
playVictorySound: function() {
|
playVictorySound: function() {
|
||||||
var position = Entities.getEntityProperties(this.entityID, "position").position;
|
var position = Entities.getEntityProperties(this.entityID, "position").position;
|
||||||
|
|
||||||
|
@ -219,8 +228,8 @@
|
||||||
Audio.playSound(VICTORY_SOUND, audioProperties);
|
Audio.playSound(VICTORY_SOUND, audioProperties);
|
||||||
|
|
||||||
},
|
},
|
||||||
update:function(){
|
|
||||||
|
|
||||||
|
update: function(deltaTime) {
|
||||||
if (THROTTLE === true) {
|
if (THROTTLE === true) {
|
||||||
sinceLastUpdate = sinceLastUpdate + deltaTime * 100;
|
sinceLastUpdate = sinceLastUpdate + deltaTime * 100;
|
||||||
if (sinceLastUpdate > THROTTLE_RATE) {
|
if (sinceLastUpdate > THROTTLE_RATE) {
|
||||||
|
@ -229,12 +238,11 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print('in update loop for maze, look for balls to clear')
|
_this.testBallDistance();
|
||||||
|
|
||||||
_this.testBallDistance()
|
|
||||||
},
|
},
|
||||||
unload:function(){
|
|
||||||
Script.update.disconnect(this.update);
|
unload: function() {
|
||||||
|
Script.update.disconnect(_this.update);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue