make blocky swipable

This commit is contained in:
James B. Pollack 2016-05-24 15:28:11 -07:00
parent c7ae3396eb
commit f1e826b305
4 changed files with 236 additions and 215 deletions

View file

@ -200,11 +200,6 @@
},
{
"angularDamping": 0,
"angularVelocity": {
"x": 0,
"y": -0.2617993950843811,
"z": 0
},
"collisionSoundURL": "atp:/kineticObjects/blocks/ToyWoodBlock.L.wav",
"created": "2016-05-09T19:30:40Z",
"dimensions": {

View file

@ -49,46 +49,41 @@ var arrangements = [{
name: 'greenhenge',
blocks: [BLOCK_GREEN, BLOCK_GREEN, BLOCK_YELLOW, BLOCK_YELLOW],
target: "atp:/blocky/newblocks1.json"
},
{
}, {
name: 'tallstuff',
blocks: [BLOCK_RED, BLOCK_RED, BLOCK_RED],
target: "atp:/blocky/newblocks2.json"
},
{
}, {
name: 'ostrich',
blocks: [BLOCK_RED, BLOCK_RED, BLOCK_GREEN, BLOCK_YELLOW, BLOCK_NATURAL],
target: "atp:/blocky/newblocks5.json"
},
{
}, {
name: 'fourppl',
blocks: [BLOCK_BLUE, BLOCK_BLUE, BLOCK_BLUE, BLOCK_BLUE, BLOCK_NATURAL, BLOCK_NATURAL, BLOCK_NATURAL, BLOCK_NATURAL],
target: "atp:/blocky/newblocks3.json"
},
{
}, {
name: 'frogguy',
blocks: [BLOCK_GREEN, BLOCK_GREEN, BLOCK_GREEN, BLOCK_YELLOW, BLOCK_RED, BLOCK_RED, BLOCK_NATURAL, BLOCK_NATURAL],
target: "atp:/blocky/newblocks4.json"
},
{
}, {
name: 'dominoes',
blocks: [BLOCK_RED, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW],
target: "atp:/blocky/arrangement6B.json"
}]
}]
var PLAYABLE_BLOCKS_POSITION = {
var PLAYABLE_BLOCKS_POSITION = {
x: 1097.6,
y: 460.5,
z: -66.22
};
};
var TARGET_BLOCKS_POSITION = {
var TARGET_BLOCKS_POSITION = {
x: 1096.82,
y: 460.5,
z: -67.689
};
//#debug
(function() {
};
//#debug
(function() {
print('BLOCK ENTITY SCRIPT')
var _this;
@ -98,13 +93,16 @@ var arrangements = [{
}
Blocky.prototype = {
busy: false,
debug: false,
playableBlocks: [],
targetBlocks: [],
preload: function(entityID) {
print('BLOCKY preload')
this.entityID = entityID;
Script.update.connect(_this.update);
},
createTargetBlocks: function(arrangement) {
var created = [];
print('BLOCKY create target blocks')
@ -119,6 +117,7 @@ var arrangements = [{
this.targetBlocks = created;
print('BLOCKY TARGET BLOCKS:: ' + this.targetBlocks);
},
createPlayableBlocks: function(arrangement) {
print('BLOCKY creating playable blocks' + arrangement.blocks.length);
arrangement.blocks.forEach(function(block) {
@ -160,12 +159,15 @@ var arrangements = [{
print('BLOCKY after going through playable arrangement')
},
startNearTrigger: function() {
print('BLOCKY got a near trigger');
this.advanceRound();
},
advanceRound: function() {
print('BLOCKY advance round');
this.busy = true;
this.cleanup();
var arrangement = arrangements[Math.floor(Math.random() * arrangements.length)];
this.createTargetBlocks(arrangement);
@ -176,7 +178,9 @@ var arrangements = [{
this.createPlayableBlocks(arrangement);
}
this.busy = false;
},
findBlocks: function() {
var found = [];
var results = Entities.findEntities(MyAvatar.position, 10);
@ -207,6 +211,7 @@ var arrangements = [{
this.targetBlocks = [];
this.playableBlocks = [];
},
debugCreatePlayableBlocks: function() {
print('BLOCKY debug create');
var howMany = 10;
@ -219,11 +224,6 @@ var arrangements = [{
collisionSoundURL: "atp:/kineticObjects/blocks/ToyWoodBlock.L.wav",
dynamic: false,
collisionless: true,
// gravity: {
// x: 0,
// y: -9.8,
// z: 0
// },
userData: JSON.stringify({
grabbableKey: {
grabbable: true
@ -245,14 +245,40 @@ var arrangements = [{
this.playableBlocks.push(Entities.addEntity(blockProps));
}
},
unload: function() {
this.cleanup();
Script.update.disconnect(_this.update);
},
clickReleaseOnEntity: function() {
print('BLOCKY click')
this.startNearTrigger();
},
update: function() {
if (this.busy === true) {
return;
}
var BEAM_TRIGGER_THRESHOLD = 0.075;
var BEAM_POSITION = {
x: 1098.5159,
y: 460.0490,
z: -66.3012
};
var leftHandPosition = MyAvatar.getLeftPalmPosition();
var rightHandPosition = MyAvatar.getRightPalmPosition();
var rightDistance = Vec3.distance(leftHandPosition, BEAM_POSITION)
var leftDistance = Vec3.distance(rightHandPosition, BEAM_POSITION)
if (rightDistance < BEAM_TRIGGER_THRESHOLD || leftDistance < BEAM_TRIGGER_THRESHOLD) {
_this.startNearTrigger();
}
}
}
return new Blocky();
})
})

View file

@ -11,18 +11,18 @@
var RESETTER_POSITION = {
x: 1098.27,
y: 460.43,
z: -66.15
x: 1098.5159,
y: 460.0490,
z: -66.3012
};
BlockyGame = function(spawnPosition, spawnRotation) {
var scriptURL ="atp:/blocky/blocky.js";
var scriptURL = "atp:/blocky/blocky.js";
var blockyProps = {
type: 'Box',
name:'home_box_blocky_resetter',
name: 'home_box_blocky_resetter',
color: {
red: 0,
green: 0,
@ -33,6 +33,7 @@ BlockyGame = function(spawnPosition, spawnRotation) {
y: 0.25,
z: 0.25
},
rotation:Quat.fromPitchYawRollDegrees(-0.0029,32.9983,-0.0021),
script: scriptURL,
userData: JSON.stringify({
"grabbableKey": {

View file

@ -330,7 +330,6 @@
y: 179.0293,
z: 89.9698
});
print('home before cuckooClock')
var cuckooClock = new MyCuckooClock({
x: 1105.5237,
@ -341,11 +340,11 @@
y: -57.0089,
z: -0.0013
});
print('home after cuckooClock')
var blocky = new BlockyGame({
x: 1098.27,
y: 460.43,
z: -66.15
x: 1098.5159,
y: 460.0490,
z: -66.3012
})
print('HOME after creating scripted entities')