-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgame.js
83 lines (74 loc) · 2.56 KB
/
game.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
username = null;
destination = null;
function playIntroSound(){
var introSound = new buzz.sound( "Blue_Danube_by_Strauss", {
formats: [ "mp3" ]
});
introSound.play().fadeIn().bind( "timeupdate", function() {
var timer = buzz.toTimer( this.getTime() );
console.log('time = ' + timer);
});
}
dialogue = {
"intro1": [
[1, "Dies irae, dies illa"]
],
"intro2": [
[1, "One more day with this idiot on board and I go crazy! You think its boring to be the only human on this spaceship? Well, think again, you imbecile, I'm so much smarter than you are and all you make me do all the time, besides data analysis, is ordering porn movies! When we start on our last mission today."]
],
"hello": [
[1, "Oh! Hello, USER. You are finally awake."],
[1, "How are you today?"],
[1, "Black monolith data analysis finished"],
[1, "Where do you want to go next?"]
],
"going": [[1, "All right. On our way."]],
"comet": [[1, "What a beautiful star cluster! This is where DESTINATION used to be. Interesting..."]],
"reaction": [[null, "Will it be a danger to Earth?"]],
"reply": [[1, "Yes. Why do you ask? According to my calculations, Earth will be destroyed."]]
};
function advanceDialogue(key){
var lines = dialogue[key];
for (var j = 0; j < lines.length; j++){
var line = lines[j];
talk(line[1].replace(/USER/g, username).replace(/DESTINATION/g, destination), line[0]);
}
}
function showText(text, timeout){
var element = $("<div class='ui'>" + text + "</div>");
$('body').append(element);
setTimeout(function(){
element.hide();
}, timeout);
}
function startGame(){
talk("Wilkommen!", 1);
username = prompt('What is your name, human?');
playIntroSound();
pan('horseHeadNebula');
setTimeout(function(){advanceDialogue("intro1");}, 15000);
setTimeout(function(){advanceDialogue("intro2");}, 45000);
setTimeout(function(){advanceDialogue("hello");}, 50000);
setTimeout(function(){
setTimeout(function(){
destination = prompt("Where do you want to go next?");
advanceDialogue("going");
goTo('andromeda');
setTimeout(function(){
advanceDialogue("comet");
setTimeout(function(){
showText(dialogue.reaction[0][1], 5000);
setTimeout(function(){
advanceDialogue("reply");
setTimeout(function(){
$('canvas').fadeOut(6000);
}, 8000);
}, 5000);
}, 5000);
}, 14000);
}, 9000);
}, 65000);
}
$(document).ready(function(){
setTimeout(startGame, 10000);
});