-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
104 lines (88 loc) · 2.48 KB
/
app.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var TITLE_SCREEN = 0;
var INTRO_SPIEL_SCREEN = 1;
var INSTRUCTIONS_SCREEN = 2;
var FEEDBACK_SCREEN = 3;
var NUM_STEPS = 7;
var currentScreen;
var grammar;
var currentBackground = 0;
function setCurrentScreen(s)
{
if (s == TITLE_SCREEN)
{
$("#titleScreen").show();
$("#introSpielScreen").hide();
$("#instructionsScreen").hide();
$("#feedbackScreen").hide();
$("#timer").hide();
$("#gongText").text("Sound the gong to start.");
$('#timerText').stopwatch({format: '{M}:{ss}'}).stopwatch('reset');
$('#timerText').text("0:00");
setBackground();
}
if (s == INTRO_SPIEL_SCREEN)
{
$("#titleScreen").hide();
$("#introSpielScreen").show();
$("#instructionsScreen").hide();
$("#feedbackScreen").hide();
$("#timer").hide();
$("#gongText").text("When you are ready, sound the gong.");
}
if (s == INSTRUCTIONS_SCREEN)
{
$("#titleScreen").hide();
$("#introSpielScreen").hide();
$("#instructionsScreen").show();
$("#feedbackScreen").hide();
$("#timer").show();
$("#gongText").text("When you are finished, sound the gong.");
$('#timerText').stopwatch({format: '{M}:{ss}'}).stopwatch('start');
$("#steps").html(grammar.flatten("#ritualInstructions#"));
}
if (s == FEEDBACK_SCREEN)
{
$("#titleScreen").hide();
$("#introSpielScreen").hide();
$("#instructionsScreen").hide();
$("#feedbackScreen").show();
$("#timer").show();
$("#gongText").text("Sound the gong to restart.");
$('#timerText').stopwatch({format: '{M}:{ss}'}).stopwatch('stop');
$("#feedback").html(grammar.flatten("#judgeFeedback#"));
}
currentScreen = s;
}
function cycleCurrentScreen()
{
var audio = $("#gongSound")[0];
audio.load();
audio.play();
if (currentScreen == FEEDBACK_SCREEN) setCurrentScreen(TITLE_SCREEN);
else setCurrentScreen(currentScreen+1);
}
function setBackground()
{
if (currentBackground == 0)
{
$("#drawing").css("background-image", "url(\"assets/candle1.png\")");
currentBackground++;
}
else if (currentBackground == 1)
{
$("#drawing").css("background-image", "url(\"assets/waterfall1.png\")");
currentBackground++;
}
else if (currentBackground == 2)
{
$("#drawing").css("background-image", "url(\"assets/rocksculpture1.png\")");
currentBackground = 0;
}
}
KeyboardController({ 32: function() { cycleCurrentScreen(); } }, 2000);
$("#gong").click(function() { cycleCurrentScreen(); });
$(document).ready(function()
{
setCurrentScreen(TITLE_SCREEN);
setTimeout(function() { grammar = tracery.createGrammar(madlibs); }, 10);
});