mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
add ping pong target and milk pail game
This commit is contained in:
parent
15745eb5b2
commit
577142a4d1
3 changed files with 184 additions and 8 deletions
|
@ -9,7 +9,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
//var position = {x:1098.4813,y:461.6781,z:-71.3820}
|
||||
// var dimensions = {x:1.0233,y:3.1541,z:0.8684}
|
||||
HoverGame = function(spawnPosition, spawnRotation) {
|
||||
|
||||
var scriptURL = "atp:/hoverGame/hoverInner.js";
|
||||
|
@ -18,11 +19,7 @@ HoverGame = function(spawnPosition, spawnRotation) {
|
|||
type: 'Model',
|
||||
modelURL: 'atp:/hoverGame/hover.fbx',
|
||||
name: 'home_model_hoverGame_container',
|
||||
dimensions: {
|
||||
x: 0.2543,
|
||||
y: 0.3269,
|
||||
z: 0.4154
|
||||
},
|
||||
dimensions: {x:1.0233,y:3.1541,z:0.8684},
|
||||
compoundShapeURL: 'atp:/hoverGame/hoverHull.obj',
|
||||
rotation: spawnRotation,
|
||||
script: scriptURL,
|
||||
|
@ -34,7 +31,7 @@ HoverGame = function(spawnPosition, spawnRotation) {
|
|||
'reset': true
|
||||
}
|
||||
}),
|
||||
dynamic: true,
|
||||
dynamic: false,
|
||||
position: spawnPosition
|
||||
};
|
||||
|
||||
|
@ -60,10 +57,16 @@ HoverGame = function(spawnPosition, spawnRotation) {
|
|||
y:-9.8,
|
||||
z:0
|
||||
},
|
||||
position: spawnPosition
|
||||
position: spawnPosition,
|
||||
userData:JSON.stringify({
|
||||
grabKey:{
|
||||
shouldCollideWith:'static'
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
var hoverContainer = Entities.addEntity(hoverContainerProps);
|
||||
var hoverBall = Entities.addEntity(hoverContainerProps);
|
||||
|
||||
function cleanup() {
|
||||
print('HOVER GAME CLEANUP!')
|
||||
|
|
78
unpublishedScripts/DomainContent/Home/pingPongGun/target.js
Normal file
78
unpublishedScripts/DomainContent/Home/pingPongGun/target.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
//
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
var _this = this;
|
||||
_this.COLLISION_COOLDOWN_TIME = 5000;
|
||||
|
||||
var startPosition = {
|
||||
x: 1100.6343,
|
||||
y: 460.5366,
|
||||
z: -65.2142
|
||||
};
|
||||
|
||||
var startRotation = Quat.fromPitchYawRollDegrees(3.1471, -170.4121, -0.0060)
|
||||
|
||||
_this.preload = function(entityID) {
|
||||
|
||||
//set our id so other methods can get it.
|
||||
_this.entityID = entityID;
|
||||
|
||||
//variables we will use to keep track of when to reset the cow
|
||||
_this.timeSinceLastCollision = 0;
|
||||
_this.shouldUntip = true;
|
||||
}
|
||||
|
||||
_this.collisionWithEntity = function(myID, otherID, collisionInfo) {
|
||||
//we dont actually use any of the parameters above, since we don't really care what we collided with, or the details of the collision.
|
||||
print('JBP TARGET COLLISION')
|
||||
//5 seconds after a collision, upright the target. protect from multiple collisions in a short timespan with the 'shouldUntip' variable
|
||||
if (_this.shouldUntip) {
|
||||
//in Hifi, preface setTimeout with Script.setTimeout
|
||||
Script.setTimeout(function() {
|
||||
_this.untip();
|
||||
_this.shouldUntip = true;
|
||||
}, _this.COLLISION_COOLDOWN_TIME);
|
||||
}
|
||||
|
||||
_this.shouldUntip = false;
|
||||
|
||||
}
|
||||
|
||||
_this.untip = function() {
|
||||
print('JBP SHOULD UNTIP')
|
||||
var props = Entities.getEntityProperties(this.entityID);
|
||||
var rotation = Quat.safeEulerAngles(props.rotation)
|
||||
if (rotation.x > 3 || rotation.x < -3 || rotation.z > 3 || rotation.z < -3) {
|
||||
print('too much pitch or roll, fix it');
|
||||
|
||||
//we zero out the velocity and angular velocity
|
||||
Entities.editEntity(_this.entityID, {
|
||||
position: startPosition,
|
||||
rotation: startRotation,
|
||||
velocity: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
angularVelocity: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
|
@ -202,6 +202,8 @@
|
|||
_this.createKineticEntities();
|
||||
_this.createScriptedEntities();
|
||||
_this.setupDressingRoom();
|
||||
_this.createMilkPailBalls();
|
||||
_this.createTarget();
|
||||
}, 750);
|
||||
}
|
||||
},
|
||||
|
@ -526,6 +528,99 @@
|
|||
var dais = Entities.addEntity(daisProperties);
|
||||
},
|
||||
|
||||
createTarget: function() {
|
||||
var targetProperties = {
|
||||
type: 'Model',
|
||||
modelURL: 'atp:/pingPongGun/Target.fbx',
|
||||
shapeType: 'Compound',
|
||||
compoundShapeURL: 'atp:/pingPongGun/Target.obj',
|
||||
dimensions: {
|
||||
x: 0.4937,
|
||||
y: 0.6816,
|
||||
z: 0.0778
|
||||
},
|
||||
rotation: Quat.fromPitchYawRollDegrees(3.1471, -170.4121, -0.0060),
|
||||
gravity: {
|
||||
x: 0,
|
||||
y: -9.8,
|
||||
z: 0
|
||||
},
|
||||
velocity: {
|
||||
x: 0,
|
||||
y: -0.1,
|
||||
z: 0
|
||||
},
|
||||
position: {
|
||||
x: 1100.6343,
|
||||
y: 460.5366,
|
||||
z: -65.2142
|
||||
},
|
||||
userData: JSON.stringify({
|
||||
grabbableKey: {
|
||||
grabbable: true
|
||||
},
|
||||
hifiHomeKey: {
|
||||
reset: true
|
||||
}
|
||||
}),
|
||||
density:100,
|
||||
dynamic: true
|
||||
}
|
||||
var target = Entities.addEntity(targetProperties);
|
||||
},
|
||||
|
||||
createMilkPailBalls: function() {
|
||||
var locations = [{
|
||||
x: 1099.0795,
|
||||
y: 459.4186,
|
||||
z: -70.8603
|
||||
}, {
|
||||
x: 1099.2826,
|
||||
y: 459.4186,
|
||||
z: -70.9094
|
||||
}, {
|
||||
x: 1099.5012,
|
||||
y: 459.4186,
|
||||
z: -71.1000
|
||||
}];
|
||||
|
||||
var ballProperties = {
|
||||
type: 'Model',
|
||||
modelURL: 'atp:/static_objects/StarBall.fbx',
|
||||
shapeType: 'Sphere',
|
||||
dimensions: {
|
||||
x: 0.1646,
|
||||
y: 0.1646,
|
||||
z: 0.1646
|
||||
},
|
||||
gravity: {
|
||||
x: 0,
|
||||
y: -9.8,
|
||||
z: 0
|
||||
},
|
||||
velocity: {
|
||||
x: 0,
|
||||
y: -0.1,
|
||||
z: 0
|
||||
},
|
||||
userData: JSON.stringify({
|
||||
grabbableKey: {
|
||||
grabbable: true
|
||||
},
|
||||
hifiHomeKey: {
|
||||
reset: true
|
||||
}
|
||||
}),
|
||||
dynamic: true
|
||||
};
|
||||
|
||||
locations.forEach(function(location) {
|
||||
ballProperties.position = location;
|
||||
var ball = Entities.addEntity(ballProperties);
|
||||
});
|
||||
print('HOME made milk pail balls')
|
||||
},
|
||||
|
||||
createTransformers: function() {
|
||||
var firstDollPosition = {
|
||||
x: 1107.6,
|
||||
|
|
Loading…
Reference in a new issue