From 979c2feeb0dc41c8dcf98618d9b64956f53a3e59 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 16 Feb 2016 12:49:28 -0800 Subject: [PATCH] tiltmaze --- .../Home/tiltMaze/ballDetector.js | 37 ++++++++ .../Home/tiltMaze/createTiltMaze.js | 90 +++++++++++++++++++ .../DomainContent/Home/tiltMaze/tiltMaze.js | 80 +++++++++++++++++ 3 files changed, 207 insertions(+) create mode 100644 unpublishedScripts/DomainContent/Home/tiltMaze/ballDetector.js create mode 100644 unpublishedScripts/DomainContent/Home/tiltMaze/createTiltMaze.js create mode 100644 unpublishedScripts/DomainContent/Home/tiltMaze/tiltMaze.js diff --git a/unpublishedScripts/DomainContent/Home/tiltMaze/ballDetector.js b/unpublishedScripts/DomainContent/Home/tiltMaze/ballDetector.js new file mode 100644 index 0000000000..4c7e7b9653 --- /dev/null +++ b/unpublishedScripts/DomainContent/Home/tiltMaze/ballDetector.js @@ -0,0 +1,37 @@ +// +// ballDetector.js +// +// Script Type: Entity +// +// Created by James B. Pollack @imgntn on 2/15/2016 +// Copyright 2016 High Fidelity, Inc. +// +// +// This script resets a ball to its original position when the ball enters it. +// +// 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; + + function BallDetctor() { + _this = this; + return; + } + + BallDetctor.prototype = { + enterEntity:function(){ + print('BALL ENTERED BALL DETECTOR!!') + }, + destroyBall:function(){ + + } + createNewBall:function(){ + + } + }; + + return new BallDetctor(); +}); \ No newline at end of file diff --git a/unpublishedScripts/DomainContent/Home/tiltMaze/createTiltMaze.js b/unpublishedScripts/DomainContent/Home/tiltMaze/createTiltMaze.js new file mode 100644 index 0000000000..c96e2c1cdf --- /dev/null +++ b/unpublishedScripts/DomainContent/Home/tiltMaze/createTiltMaze.js @@ -0,0 +1,90 @@ + var ball, ballDetector, tiltMaze; + var MAZE_MODEL_URL = "http://hifi-content.s3.amazonaws.com/DomainContent/Home/tiltMaze/MAZE2.fbx"; + var MAZE_COLLISION_HULL = "http://hifi-content.s3.amazonaws.com/DomainContent/Home/tiltMaze/MAZE_COLLISION_HULL.obj"; + var BALL_DETECTOR_SCRIPT = Script.resolvePath('ballDetector.js?' + Math.random()) + + + var MAZE_DIMENSIONS = { + x: 1, + y: 0.3, + z: 1 + }; + + var BALL_DIMENSIONS = { + x: 0.1, + y: 0.1, + z: 0.1 + } + var BALL_COLOR = { + red: 255, + green: 0, + blue: 0 + } + + var DEBUG_COLOR = { + red: 0, + green: 255, + blue: 0 + } + + + var createBall = function(position) { + var properties = { + name: 'Hifi Tilt Maze Ball' + type: 'Sphere', + shapeType: 'sphere', + dimensions: BALL_DIMENSIONS, + color: BALL_COLOR, + position: position + dynamic: true, + }; + ball = Entities.addEntity(properties); + }; + + var createBallSpawningAnchor: function() { + var properties = { + name: 'Hifi Tilt Maze Ball Detector' + parentID: tiltMaze, + type: 'Box', + dimensions: BALL_DETECTOR_DIMENSIONS, + position: position, + rotiation: rotation, + collisionless: true, + script: BALL_DETECTOR_SCRIPT + }; + } + + var createBallDetector = function(position, rotation) { + var properties = { + name: 'Hifi Tilt Maze Ball Detector' + parentID: tiltMaze, + type: 'Box', + dimensions: BALL_DETECTOR_DIMENSIONS, + position: position, + rotiation: rotation, + collisionless: true, + script: BALL_DETECTOR_SCRIPT + }; + ballDetector = Entities.addEntity(properties); + }; + + var createTiltMaze: function(position, rotation) { + var properties = { + name: 'Hifi Tilt Maze', + type: 'Model', + compoundShapeURL: MAZE_COLLISION_HULL, + dimensions: MAZE_DIMENSIONS, + position: position, + rotation: rotation, + dynamic: true, + } + tiltMaze = Entities.addEntity(properties) + } + + var createAll = function() { + createTiltMaze(); + // createBallDetector(); + // createBall(); + } + + createAll(); \ No newline at end of file diff --git a/unpublishedScripts/DomainContent/Home/tiltMaze/tiltMaze.js b/unpublishedScripts/DomainContent/Home/tiltMaze/tiltMaze.js new file mode 100644 index 0000000000..da2c4eef7b --- /dev/null +++ b/unpublishedScripts/DomainContent/Home/tiltMaze/tiltMaze.js @@ -0,0 +1,80 @@ +// +// tiltMaze.js +// +// Script Type: Entity +// +// Created by James B. Pollack @imgntn on 2/15/2016 +// Copyright 2016 High Fidelity, Inc. +// +// +// This is the entity script for a tilt maze. It create a ball when you grab it, which you have a set amount of time to get through the hole +// +// 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 COLLISION_HULL = ""; + var MAZE_MODEL = ""; + var LENGTH_OF_GAME = 60; + + var BALL_DETECTOR_SCRIPT = Script.resolvePath('ballDetector.js?' + Math.random()) + var _this; + + function TiltMaze() { + _this = this; + return; + } + + TiltMaze.prototype = { + hasBall: false, + hand: null, + startNearGrab: function(entityID, args) { + this.hand = args[0]; + + }, + releaseGrab: function() { + + }, + + preload: function(entityID) { + this.entityID = entityID; + }, + + createBall: function(position) { + var properties = { + type: 'Sphere', + shapeType: 'sphere', + dimensions: BALL_DIMENSIONS, + color: BALL_COLOR, + position: position + }; + this.ball = Entities.addEntity(properties); + }, + + createBallDetector: function(position, rotation) { + var properties = { + parentID: this.entityID, + type: 'Box', + dimensions: BALL_DETECTOR_DIMENSIONS, + position: position, + rotiation: rotation, + collisionless: true, + script: BALL_DETECTOR_SCRIPT + }; + this.ballDetector = Entities.addEntity(properties); + }, + + destroyBall: function() { + Entities.deleteEntity(this.ball); + } + + unload: function() { + + + }, + + }; + + return new TiltMaze(); +}); \ No newline at end of file