Skip to content

Commit 67e8c79

Browse files
committed
Add title text and instructions
1 parent 4422baa commit 67e8c79

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

public/scripts.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function oscillateCamera() {
8181
}
8282

8383
var yeahboi_text = null;
84-
var yeahboi_text_position = -4.4;
84+
var yeahboi_text_position = -4.65;
8585

8686
var setupText = function () {
8787
var loader = new THREE.FontLoader();
@@ -110,7 +110,7 @@ setupText();
110110

111111
var sound = new Howl({
112112
src: ['/mp3/sound.mp3'],
113-
autoplay: true,
113+
autoplay: false,
114114
loop: true,
115115
volume: 0.25,
116116
onend: function() {
@@ -120,13 +120,32 @@ var sound = new Howl({
120120

121121
var frame = 0;
122122

123-
var lose = lose_dialog_shown = false;
123+
var lose = lose_dialog_shown = started = false;
124+
125+
var titletext = document.createElement('div');
126+
titletext.style.position = 'absolute';
127+
titletext.style.width = 500;
128+
titletext.style.height = 500;
129+
//titletext.style['font-face'] = 'Impact';
130+
titletext.innerHTML = 'Press spacebar to jump. Click here to begin';
131+
titletext.style.top = '42%';
132+
titletext.style.left = '42%';
133+
titletext.addEventListener("click", function (e) {
134+
sound.play();
135+
started = true;
136+
e.target.innerHTML = '';
137+
}, false);
138+
document.body.appendChild(titletext);
124139

125140
var animate = function () {
126-
frame++;
127-
128141
requestAnimationFrame( animate );
129142

143+
if (! started) {
144+
return renderer.render(scene, camera);
145+
}
146+
147+
frame++;
148+
130149
if (lose) {
131150
if (! lose_dialog_shown) {
132151
lose_dialog_shown = true;
@@ -215,7 +234,7 @@ var animate = function () {
215234
}
216235
}
217236

218-
if (frame % 25 === 0) {
237+
if (frame % 20 === 0) {
219238
var trail = new THREE.Mesh(
220239
geometry,
221240
new THREE.MeshBasicMaterial( { color: 0x444444, opacity: 0.8, transparent: true } )

0 commit comments

Comments
 (0)