-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea43bc2
commit 900d71d
Showing
3 changed files
with
155 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Flock standalone example</title> | ||
|
||
<style> | ||
body { | ||
font-family: "Asap", Helvetica, Arial, Lucida, sans-serif !important; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Flock!</h1> | ||
|
||
<canvas id="renderCanvas" touch-action="none" style="width: 640px; height: 360px;" tabindex="0"></canvas> | ||
</div> | ||
|
||
<script id="flock" type="application/flock"> | ||
// Made with Flock XR | ||
var player = 'player'; var cylinder5 = 'cylinder5'; var box2 = 'box2'; var box1 = 'box1'; var jumping = 'jumping'; var cylinder3 = 'cylinder3'; var sound1 = 'sound1'; var object1 = 'object1'; var cylinder4 = 'cylinder4'; var cylinder6 = 'cylinder6'; | ||
|
||
(async () => { | ||
printText('🌈 Welcome to Flock XR', 30, "#000080"); | ||
printText('Use WASD to walk around', 30, "#000080"); | ||
box2 = createBox("box2", "#333333", 2, 1, 0.5, [(-1.2), 0.6, (-2.2)]); | ||
|
||
cylinder6 = createCylinder("cylinder6", "#666666", 0.1, 0.6, 0.6, 24, [(-0.6), 0.6, (-1.9)]); | ||
await rotateTo(cylinder6, 90, 180, 180); | ||
|
||
cylinder6 = createCylinder("cylinder6", "#666666", 0.1, 0.6, 0.6, 24, [(-1.8), 0.6, (-1.9)]); | ||
await rotateTo(cylinder6, 90, 180, 180); | ||
|
||
})(); | ||
|
||
(async () => { | ||
box1 = createBox("box1", "#cc9933", 10, 0.1, 10, [0, 0.05, 0]); | ||
|
||
object1 = newObject({ | ||
modelName: 'hut.glb', | ||
modelId: 'hut.glb__7', | ||
color: ["#2a9d8f", "#e9c46a", "#e76f51"], | ||
scale: 1, | ||
position: { x: 0, y: 0, z: 0 }, | ||
callback: async function() { | ||
await positionAt(object1, 0, 4.5, 0, true); | ||
await scaleMesh(object1, 10, 6, 10, 'CENTRE', 'BASE', 'CENTRE'); | ||
await rotateTo(object1, 0, (-90), 0); | ||
await setPhysicsShape(object1, "MESH"); | ||
|
||
} | ||
}); | ||
})(); | ||
|
||
(async () => { | ||
cylinder3 = createCylinder("cylinder3", "#666666", 0.2, 1, 1, 24, [2, 0.1, (-1)]); | ||
|
||
cylinder4 = createCylinder("cylinder4", "#666666", 2.4, 0.1, 0.1, 24, [2, 1.5, (-1)]); | ||
|
||
cylinder5 = createCylinder("cylinder5", "#ffcc00", 1, 1, 2, 24, [2, 2.2, (-1)]); | ||
|
||
})(); | ||
|
||
(async () => { | ||
setSky("#6495ed"); | ||
createGround("#71bc78", "ground"); | ||
buttonControls("BOTH", false, "#ffffff"); | ||
})(); | ||
|
||
(async () => { | ||
jumping = false; | ||
player = newCharacter({ | ||
modelName: 'Character1.glb', | ||
modelId: 'Character1.glb__8', | ||
scale: 0.75, | ||
position: { x: 0.3, y: 0.3, z: 10 }, | ||
colors: { | ||
hair: "#000000", | ||
skin: "#a15c33", | ||
eyes: "#000000", | ||
sleeves: "#008b8b", | ||
shorts: "#00008b", | ||
tshirt: "#ff8f60" | ||
} | ||
}); | ||
await setPhysics(player, "DYNAMIC"); | ||
await attachCamera(player, 5); | ||
})(); | ||
|
||
onIntersect(player, cylinder5, "OnIntersectionEnterTrigger", async function() { | ||
|
||
await glow(cylinder5); | ||
|
||
}); | ||
|
||
onIntersect(player, box1, "OnIntersectionExitTrigger", async function() { | ||
|
||
await clearEffects(cylinder5); | ||
|
||
}); | ||
|
||
onTrigger(box2, "OnPickTrigger", [ | ||
async function() { | ||
flock.playSound(box2, "theme-electronic.ogg", {"playbackRate":1,"volume":1,"loop":false}); | ||
} | ||
], { mode: "wait" }); | ||
|
||
forever(async () => { | ||
if (jumping && (isTouchingSurface(player))) { | ||
jumping = false; | ||
broadcastEvent('landed'); | ||
} | ||
if ((keyPressed(" ")) && !jumping) { | ||
applyForce(player, 0, 5, 0); | ||
jumping = true; | ||
broadcastEvent('jumped'); | ||
} | ||
if (keyPressed("w")) { | ||
moveForward(player, 8); | ||
} else if (keyPressed("s")) { | ||
moveForward(player, (-8)); | ||
} else if (keyPressed("a")) { | ||
moveSideways(player, 5); | ||
} else if (keyPressed("d")) { | ||
moveSideways(player, (-5)); | ||
} | ||
if (!jumping) { | ||
if ((keyPressed("w")) || (keyPressed("s")) || (keyPressed("a")) || (keyPressed("d"))) { | ||
await switchAnimation(player, "Walk"); | ||
} else { | ||
await switchAnimation(player, "Idle"); | ||
} | ||
} | ||
}); | ||
|
||
onEvent('jumped', async function() { | ||
await playAnimation(player, "Jump"); | ||
await switchAnimation(player, "Jump_Idle"); | ||
}); | ||
|
||
onEvent('landed', async function() { | ||
await playAnimation(player, "Jump_Land"); | ||
}); | ||
</script> | ||
|
||
<script type="module"> | ||
import "https://flipcomputing.github.io/flock/flock.js"; | ||
</script> | ||
</body> | ||
</html> |