Skip to content

Commit e43d9f9

Browse files
committed
Initial Commit
Currently working with tap to create a cluster of oranges that can be eaten
1 parent 3f3216f commit e43d9f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3864
-0
lines changed
35.6 KB
Binary file not shown.
35.6 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

AdditionalFiles/OrangeFXB/Materials/folder.lock

Whitespace-only changes.

FoodEat.lsproj

+2,589
Large diffs are not rendered by default.

LICENSE.txt

846 Bytes
Binary file not shown.

Public/Behavior.js

+920
Large diffs are not rendered by default.

Public/Default/echopark_diff.png

2.66 KB

Public/Default/echopark_spec.png

269 KB

Public/Default/folder.lock

Whitespace-only changes.

Public/Fonts/folder.lock

Whitespace-only changes.

Public/Fonts/jellee_roman.ttf

45 KB
Binary file not shown.

Public/Gold.lsmat

36 KB
Binary file not shown.

Public/Occluder.lsmat

7.28 KB
Binary file not shown.

Public/Orange Container.oprfb

98.4 KB
Binary file not shown.

Public/Orange.oprfb

93.8 KB
Binary file not shown.

Public/OrangeFXB.fbx

27.9 KB
Binary file not shown.

Public/Scripts/EndGame.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// EndGame.js
2+
// Version: 0.0.1
3+
// Event: Tapped
4+
// Description: Calls the end game api on Tapped
5+
6+
// @input Component.ScriptComponent highScoreController
7+
8+
script.highScoreController.api.endGame();

Public/Scripts/Food.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// -----JS CODE-----
2+
// @input Component.ScriptComponent behaviorScript
3+
4+
5+
var eaten = false;
6+
global.canEat = true;
7+
//When the object is eaten
8+
function eat() {
9+
if (global.canEat) {
10+
unbindCollisionDetection();
11+
script.getSceneObject().enabled = false;
12+
global.canEat = false;
13+
global.scBehaviorSystem.sendCustomTrigger("Increment Score");
14+
eaten = true;
15+
}
16+
}
17+
18+
function unbindCollisionDetection() {
19+
script.behaviorScript.api.removeTriggerResponse(mouthCollision)
20+
}
21+
function onMouthClosed(eventData) {
22+
//Debug statement
23+
//print("mouth was closed --food.js");
24+
25+
//This asks if the mouth is colliding with the current object,
26+
script.behaviorScript.api.addTriggerResponse(mouthCollision);
27+
28+
//Delay removing the trigger response by 0.1seconds to give a window of opportunity for it to trigger
29+
var event = script.createEvent("DelayedCallbackEvent");
30+
event.bind(unbindCollisionDetection);
31+
event.reset(0.1);
32+
33+
}
34+
function onMouthOpened(eventData) {
35+
global.canEat = true;
36+
}
37+
38+
function mouthCollision() {
39+
//Debug Statement
40+
//print("mouth collided --food.js");
41+
42+
//This function abstracts 'eat', as this function can ONLY be called if both the mouth closed event AND the mouth collision event are triggered.
43+
if (!eaten) {
44+
eat();
45+
}
46+
}
47+
48+
var event = script.createEvent("MouthClosedEvent");
49+
event.bind(onMouthClosed);
50+
51+
var event = script.createEvent("MouthOpenedEvent");
52+
event.bind(onMouthOpened);
53+
54+
if (!script.behaviorScript) {
55+
return;
56+
}
57+
58+

Public/Scripts/FoodController.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// -----JS CODE-----
2+
// @input Asset.ObjectPrefab orangeContainer
3+
// @input Component.Camera camera
4+
script.createEvent("TouchStartEvent").bind(onTouchStart);
5+
function onTouchStart(e) {
6+
print("Screen Touched");
7+
if (script.camera) {
8+
var touchPosition = e.getTouchPosition();
9+
var worldPosition = script.camera.screenSpaceToWorldSpace(touchPosition, 0);
10+
var mySceneObject = createObjectFromPrefab();
11+
mySceneObject.getTransform().setWorldPosition(worldPosition);
12+
}
13+
}
14+
function createObjectFromPrefab() {
15+
if (script.orangeContainer) {
16+
var instanceObject = script.orangeContainer.instantiate(script.getSceneObject());
17+
return instanceObject;
18+
}
19+
else {
20+
return undefined;
21+
}
22+
}

Public/Scripts/GetPosition.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// -----JS CODE-----
2+
3+
//@input SceneObject
4+
//@input Component.ScriptComponent highScoreController
5+
6+
script.highScoreController.api.incrementScore();
7+
8+
var transform = script.getTransform();
9+
var sphereTransform = script.otherSphere.getTransform();
10+
print(transform.getLocalPosition().x);
11+
print(sphereTransform.getLocalPosition().x);
12+
//print(transform.getWorldPosition().y);

Public/Scripts/Gravity.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// -----JS CODE-----
2+
var transform = script.getTransform();
3+
var pos = transform.getWorldPosition();
4+
pos.y -= 0.1;
5+
transform.setWorldPosition(pos);

Public/Scripts/IncrementScore.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// IncrementScore.js
2+
// Version: 0.0.1
3+
// Event: Tapped
4+
// Description: Calls the increment score api on Tapped
5+
6+
// @input Component.ScriptComponent highScoreController
7+
8+
global.scBehaviorSystem.addCustomTriggerResponse("Increment Score", script.highScoreController.api.incrementScore);

Public/Scripts/Rotate.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// -----JS CODE-----
2+
var transform = script.getTransform();
3+
var rotation = transform.getLocalRotation();
4+
var rotateBy = quat.angleAxis(Math.PI * getDeltaTime(), vec3.up());
5+
rotation = rotation.multiply(rotateBy);
6+
transform.setLocalRotation(rotation);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// SimpleHighScoreController.js
2+
// Version: 0.0.1
3+
// Event: Lens Initialized
4+
// Description: A simple example of saving a high score with the persistent storage system
5+
6+
// @input Component.Text scoreText
7+
// @input Component.Text highScoreText
8+
9+
var currentScore = 0;
10+
var highScore = 0;
11+
12+
// Define the key which the persistent storage system will use to save the data to
13+
const highScoreKey = "hs_template_high_score";
14+
15+
// Get the data associated with the key from the persistent storage system
16+
var persistentStorageSystem = global.persistentStorageSystem.store;
17+
highScore = persistentStorageSystem.getFloat(highScoreKey) || 0;
18+
19+
// Update the high score label
20+
updateHighScoreText();
21+
22+
// Script API interface
23+
script.api.incrementScore = incrementScore;
24+
script.api.endGame = endGame;
25+
26+
function updateScoreText() {
27+
script.scoreText.text = currentScore.toString();
28+
}
29+
30+
function updateHighScoreText() {
31+
script.highScoreText.text = highScore.toString();
32+
}
33+
34+
function incrementScore() {
35+
currentScore++;
36+
updateScoreText();
37+
}
38+
39+
function setHighScore() {
40+
if( currentScore > highScore ) {
41+
highScore = currentScore;
42+
43+
// Set the data associated with the key from the persistent storage system
44+
persistentStorageSystem.putFloat(highScoreKey, currentScore);
45+
46+
// Update the high score text since its been updated
47+
updateHighScoreText();
48+
}
49+
}
50+
51+
function resetGame() {
52+
currentScore = 0;
53+
updateScoreText();
54+
}
55+
56+
function endGame() {
57+
setHighScore();
58+
resetGame();
59+
}

Public/Scripts/Test.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// -----JS CODE-----
2+
function printTime(eventData) {
3+
// Print the elapsed Lens time
4+
print(getTime().toString());
5+
}
6+
// Bind the function printTime to the event UpdateEvent
7+
var event = script.createEvent("UpdateEvent");
8+
event.bind(printTime);

Public/Scripts/Unused/AABB.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// -----JS CODE-----
2+
3+
//@input float width
4+
//@input float height
5+
//@input float breadth
6+
//@input Component.ScriptComponent detect
7+
8+
script.api.minX = 0;
9+
script.api.minY = 0;
10+
script.api.minZ = 0;
11+
script.api.maxX = 0;
12+
script.api.maxY = 0;
13+
script.api.maxZ = 0;
14+
15+
function Register() {
16+
if (script.detect.api) { //don't do the first call
17+
script.detect.api.AddAABB(script);
18+
}
19+
}
20+
21+
script.api.MinMaxCalculations = function () {
22+
var position = script.getSceneObject().getTransform().getWorldPosition();
23+
var halfW = script.width / 2.0;
24+
var halfH = script.height / 2.0;
25+
var halfB = script.breadth / 2.0;
26+
27+
script.api.minX = position.x - halfW;
28+
script.api.minY = position.y - halfH;
29+
script.api.minZ = position.Z - halfB;
30+
31+
script.api.maxX = position.x + halfW;
32+
script.api.maxY = position.y + halfH;
33+
script.api.maxZ = position.Z + halfB;
34+
print("calculated min max")
35+
}
36+
37+
Register();
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// -----JS CODE-----
2+
// @input Component.ScriptComponent highScoreController
3+
// @input SceneObject[] foods
4+
// @input Component.ScriptComponent behaviorScript
5+
// @input Component.ScriptComponent sphere
6+
7+
//Bind to custom event call
8+
function incrementScore() {
9+
script.highScoreController.api.incrementScore();
10+
}
11+
function eatOneSphere() {
12+
script.api.sphere.eatIfColliding();
13+
}
14+
script.behaviorScript.api.addTriggerResponse(eatOneSphere);
15+
//global.scBehaviorSystem.addCustomTriggerResponse("Sphere Ate", incrementScore);
16+
17+
//function setupDistanceCheck() {
18+
// if (!(script.distanceCheckObjectA && script.distanceCheckObjectB)) {
19+
// return;
20+
// }
21+
// var transformA = script.distanceCheckObjectA.getTransform();
22+
// var transformB = script.distanceCheckObjectB.getTransform();
23+
// whenCompareTypeMatches(function () {
24+
// return transformA.getWorldPosition().distance(transformB.getWorldPosition());
25+
// }, script.distanceCheckDistance, script.distanceCheckCompareType, onTrigger, script.distanceCheckAllowRepeat, false);
26+
//}
27+

Public/Scripts/Unused/detect.js

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// -----JS CODE-----
2+
3+
//@input Component.ScriptComponent collider
4+
var colliders = [];
5+
var collide1;
6+
var collide2;
7+
var collide3;
8+
9+
script.api.AddAABB = function (AABB) {
10+
colliders.push(AABB)
11+
AABB.api.MinMaxCalculations();
12+
print(AABB.api.minX);
13+
print("added an AABB");
14+
15+
//if (collide1 != null) {
16+
// if (collide2 != null) {
17+
// if (collide3 != null) {
18+
// print(colliders.push(AABB));
19+
// } else {
20+
// collide3 = AABB;
21+
// print(intersect(collide1, collide2));
22+
// }
23+
// } else {
24+
// collide2 = AABB;
25+
// }
26+
//}
27+
//else {
28+
// collide1 = AABB;
29+
//}
30+
}
31+
32+
function intersect(a, b) {
33+
return (a.api.minX <= b.api.maxX && a.api.maxX >= b.api.minX) &&
34+
(a.api.minY <= b.api.maxY && a.api.maxY >= b.api.minY) &&
35+
(a.api.minZ <= b.api.maxZ && a.api.maxZ >= b.api.minZ);
36+
}
37+
38+
function checkCollisions() {
39+
for (x = 0; colliders.length -3 ; x++) {
40+
//try {
41+
// print(colliders[x])
42+
var AABB = colliders[x];
43+
AABB.api.MinMaxCalculations();
44+
print("started checking collisions, just did minmax")
45+
//} catch (err) {
46+
// colliders.splice(x, 1);
47+
// x--;
48+
//}
49+
}
50+
51+
for (x = 0; colliders.length; x++) {
52+
for (y = x+1; y < colliders.length; y++) {
53+
var colX = colliders[x];
54+
var colY = colliders[y];
55+
if (intersect(colX, colY)) {
56+
//tell the scripts they intersect
57+
print("X AND Y INTERSECTED");
58+
//colX.api.Intersection(colY);
59+
//colY.api.Intersection(colX);
60+
}
61+
}
62+
}
63+
64+
}
65+
66+
var event = script.createEvent("UpdateEvent");
67+
event.bind(checkCollisions);

Public/Scripts/Unused/folder.lock

Whitespace-only changes.
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// -----JS CODE-----
2+
// @input bool eaten
3+
// @input bool mouthOpen
4+
// @input Component.ScriptComponent highScoreController
5+
// @input Component.ScriptComponent behaviorScript
6+
7+
script.eaten = false;
8+
script.mouthOpen = false;
9+
function ate() {
10+
//is sphere collision source
11+
if (script.eaten == false) {
12+
script.highScoreController.api.incrementScore();
13+
script.getSceneObject().enabled = false;
14+
}
15+
script.eaten = true;
16+
}
17+
18+
function mouthCollision() {
19+
if (!script.mouthOpen)
20+
ate();
21+
}
22+
//script.addCustomTriggerResponse("Sphere Collision")
23+
//script.addCustomTriggerResponse("Sphere Ate", mouthCollision);
24+
//script.behaviorScript.api.addTriggerResponse(mouthCollision);
25+
26+
function eatIfColliding() {
27+
print('ate');
28+
}
29+
30+
31+
var mouthOpenEvent = script.createEvent("MouthOpenedEvent");
32+
mouthOpenEvent.faceIndex = 0;
33+
mouthOpenEvent.bind(function (eventData) { script.mouthOpen = true; })
34+
35+
var mouthClosedEvent = script.createEvent("MouthClosedEvent");
36+
mouthClosedEvent.faceIndex = 0;
37+
mouthClosedEvent.bind(function (eventData) { script.mouthOpen = false; })
38+

Public/Scripts/folder.lock

Whitespace-only changes.

Public/Sphere 2.oprfb

69 KB
Binary file not shown.

Public/Sphere.mesh

29.5 KB
Binary file not shown.

Public/Textures/add_point.png

8.57 KB

Public/Textures/end_game.png

7.95 KB

Public/Textures/folder.lock

Whitespace-only changes.
65.5 KB

Public/Textures/white.png

83 Bytes

Public/folder.lock

Whitespace-only changes.

icon.png

29.2 KB

project.data

1.85 MB
Binary file not shown.

0 commit comments

Comments
 (0)