-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
395 lines (350 loc) · 15.2 KB
/
index.html
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<!-- Caching -->
<!-- html manifest="cache.manifest" -->
<head>
<title>Virion</title>
<link rel="shortcut icon" href="images/logo/logo32.png" />
<link type="text/css" href="css/ui-darkness/jquery-ui-1.8.9.custom.css" rel="stylesheet" />
<link type="text/css" href="css/styles.css" rel="stylesheet" />
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-21739289-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body style="background:white; overflow-x: hidden">
<div id="whole-page-intro-overlay" style="text-align: center; vertical-align: center; position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 100; background: white">
<div id="intro-loading-text" style="color: black; font-size: 16px; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); overflow: hidden; white-space: nowrap;"> <!-- Center horizontally and vertically -->
L O A D I N G
</div>
</div>
<!-- Facebook Integration
All of this is just to set g_user_id and g_user_name
-->
<!-- This initialized the SDK so we can use it -->
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId:179028108782663, cookie:true,
status:true, xfbml:true
});
// Reload when user logs in (like with the fb login button)
// use a timeout to avoid safari looping bug
// nobody will log in within 2 seconds anyway
setTimeout(function() {
FB.Event.subscribe('auth.login', function(response) {
//console.log(response);
if (parent) {
parent.location = "http://apps.facebook.com/viriongame/";//.reload();
}
else {
window.location.reload();
}
});
}, 2000);
</script>
<script>
// If user is already logged in, then refresh to get
// the auth token
var fb_login_button;
// We want to avoid fading in the page before we know if the user is logged in to avoid a flicker.
var CHECKED_USER_LOGIN_STATUS = false;
if(window.location.hash.length == 0)
{
var url = "https://www.facebook.com/dialog/oauth?client_id= \
179028108782663&redirect_uri=" + window.location +
"&response_type=token";
//window.open(url);
//window.location = url;
FB.getLoginStatus(function(response) {
if (response.status === 'connected') { //logged in and known
window.location=url;
}
else {
//window.location = window.location + "1";
}
CHECKED_USER_LOGIN_STATUS = true;
})
// Add fb login button if user is not logged in
//document.write(
fb_login_button = ' \
<!-- FB Login Button --> \
<div id="fb_login_button" style="postion:absolute;left:0;"> \
<div id="child_div"> \
<fb:login-button> \
Login with Facebook to track your high scores \
</fb:login-button> \
</div> \
</div> '
//);
} else { // access token in URL
CHECKED_USER_LOGIN_STATUS = true;
accessToken = window.location.hash.substring(1);
// This shouldn't actually be needed to get the friends list, but it
// isn't working withot it for some reason. So keep it around for later.
window.g_ACCESS_TOKEN = accessToken;
// Only update if hash is from facebook
//console.log(accessToken.indexOf('access_token'));
if (accessToken.indexOf('access_token') !== -1) {
graphUrl = "https://graph.facebook.com/me?" + accessToken +
"&callback=got_user"
//use JSON-P to call the graph
var script = document.createElement("script");
script.src = graphUrl;
document.body.appendChild(script);
}
}
//initialize global user variables to null
g_user_id = null;
g_user_name = null;
// Has an array of objects, where each object has a name and an id field
g_friends_list = [];
g_get_friends = function() {
var all_friend_ids = [];
for_each(g_friends_list, function(o) {
all_friend_ids.push(o.id);
});
return all_friend_ids;
};
// This 'user' object has all the info from fb
function got_user(user) {
console.log('got user');
//userName.innerText = user.name;
//console.log("user id: " + user.id);
// Error checking, only update if it went correctly
if (user.id) {
//Global vars for Unique User ID and name
g_user_id = user.id;
g_user_name = user.name;
// do scores after setting name and id
//scores.do_scores();
// Display name
/*
console.log("Adding name");
var name_div = document.getElementById('fb_name_div');
name_div.innerHTML = "";//"Your are logged in as " + g_user_name;
// Remove fb login button
var login_div = document.getElementById("fb_login_button");
login_div.parentNode.removeChild(login_div);
*/
// Set friends list
FB.api('/me/friends?' + g_ACCESS_TOKEN, function(response) {
//console.log("AAA " + response.data);
g_friends_list = response.data;
});
}
else {
console.log("Error in getting facebook info");
}
}
</script>
<!-- <div id="fb_name_div"> You are not Logged In</div> -->
<div>
<div style="margin-top:1em; font-family: Roboto sans-serif; font-size: 20px">
<!-- Score -->
<!-- Removing because its annoying when hiding all divs for theater mode. I don't think we're even using it anymore? -->
<div id="scores-wrap">
<div id="scores">
</div>
</div>
<div class="pure-button theater-disable" style="font-size: 14px"> + More Info</div>
<div class="pure-button theater-enable" style="display: none; font-size: 14px"> Enable Theater Mode </div>
<div class="fb-login-button" style="margin-bottom: 25px">
<script>
if (fb_login_button) {
document.write(fb_login_button);
}
</script>
</div>
<!-- Game Canvas -->
<div class="dont-hide-in-theater canvas-wrapper" style="width: 700px; height: 600px; margin: 0 auto"> <!-- margin here is to center horizontally" margin: 0 auto-->
<canvas class="dont-hide-in-theater" width="700" height="600" id="test_canvas">
Your browser does not support the HTML5 canvas element. Upgrade to Chrome, Firefox 4, Safari, or Opera to play this game.
</canvas>
</div>
<!--<div style="float:right; margin: 1.5em -5px 0.5em 1.5em; padding:0.5em; border: 1px dashed black; font-size:0.8em; width:200;">
<div style="margin-bottom:0.5em; font-weight:bold;">Virion was the first place finisher in the 2010-2011 Hidden Agenda Competition!</div>
<a href="http://www.facebook.com/haproject" target="_blank"><img src="images/halogo.jpg" width="200" /></a>
</div>-->
<div style="color: black; margin-top: 5em; /*margin-bottom:4em;*/ font-size: 0.8em;">
<div> Virion was the winner of the 2011 Hidden Agenda educational game competition. The game is intended to teach kids (or adults!) about the basic workings of the human immune system.
Players who fully grasp the mechanics of the game will also have absorbed a general intuition about the first line of defence in our bodies, including macrophages, antibodies, T-Cells, and granulocytes.
</div>
<div style="margin-top: 10px"> Virion was built using the open HTML5 standard, the <a target="_blank" href="http://processingjs.org">Processing.js</a> JavaScript library, and no proprietary plugins. The entire source code is available on <a target="_blank" href="https://github.com/vjsingh/Virus-Game">Github</a>.
</div>
<div style="margin-top: 10px">Please contact us at [email protected] if you have any questions, comments, or suggestions. Thank you for playing, and we hope you enjoyed it!</div>
<div style="margin-top: 10px; font-size: 13px">(And thank you to the beautiful <a target="_blank" href="http://www.mattwetmore.me">Matt Wetmore</a> for hosting us)</div>
<br/><br/> </div>
</div>
</div>
<a id="fork-me-baby" target="_blank" href="https://github.com/vjsingh/Virus-Game"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png" alt="Fork me on GitHub"></a>
<!-- Jplayer divs
These must be at the beginning (I think before sound.js)
-->
<div id="jquery_jplayer_0" class="jp-jplayer"></div>
<div id="jquery_jplayer_1" class="jp-jplayer"></div>
<div id="jquery_jplayer_2" class="jp-jplayer"></div>
<div id="jquery_jplayer_3" class="jp-jplayer"></div>
<div id="jquery_jplayer_4" class="jp-jplayer"></div>
<div id="jquery_jplayer_5" class="jp-jplayer"></div>
<div id="jquery_jplayer_6" class="jp-jplayer"></div>
<div id="jquery_jplayer_7" class="jp-jplayer"></div>
<div id="jquery_jplayer_8" class="jp-jplayer"></div>
<div id="jquery_jplayer_9" class="jp-jplayer"></div>
<div id="jquery_jplayer_bg_0" class="jp-jplayer"></div>
<div id="jquery_jplayer_bg_1" class="jp-jplayer"></div>
<div id="jquery_jplayer_bg_2" class="jp-jplayer"></div>
<div id="jquery_jplayer_bg_3" class="jp-jplayer"></div>
<div id="jquery_jplayer_menu" class="jp-jplayer"></div>
<div id="jquery_jplayer_buttons" class="jp-jplayer"></div>
<!-- <audio id="changes" src="C:\Users\JKoh\Music\2Pac\Greatest Hits\05 Changes.mp3" preload="auto">
</audio> -->
<audio id="cell_fire" src="sounds/cell_fire.ogg">
</audio>
<audio id="cell_infect" src="sounds/cell_infect.ogg">
</audio>
<audio id="macrophage_infect" src="sounds/macrophage_infect.ogg">
</audio>
<!-- <audio id="heart_loop1" src="sounds/heart_loop1.mp3" preload="auto" loop>
</audio> -->
<audio id="level_up" src="sounds/level_up.ogg">
</audio>
<audio id="kill" src="sounds/kill.ogg">
</audio>
<audio id="TextPopUp" src="sounds/TextPopUp.ogg">
</audio>
<!-- Sounds and Images -->
<!--
<script src="processing-1.0.0.min.js"></script>
-->
<script src="processing-1.0.0.js"></script>
<script type="text/javascript" src="php_functions.php"></script>
<script src="jquery-1.4.4.min.js"></script>
<script src="jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="jplayer/jquery.jplayer.min.js"></script>
<script src="global_functions.js"></script>
<script src="sound.js"></script>
<script src="settings.js"></script>
<script src="image_manager.js"></script>
<script src="animated_image.js"></script>
<script src="loading_state.js"></script>
<script src="game_object.js"></script>
<script src="wall_segment.js"></script>
<script src="particle.js"></script>
<script src="cell.js"></script>
<script src="wall_cell.js"></script>
<script src="empty_cell.js"></script>
<script src="floater.js"></script>
<script src="tkiller.js"></script>
<script src="game_state.js"></script>
<script src="in_game_state.js"></script>
<script src="generator.js"> </script>
<script src="rectangle.js"></script>
<script src="options_state.js"></script>
<script src="option_button.js"></script>
<script src="help_state.js"></script>
<script src="splash_state.js"></script>
<script src="credits_state.js"></script>
<script src="button.js"></script>
<script src="state_manager.js"></script>
<script src="pause_state.js"></script>
<script src="game_over_state.js"></script>
<script src="high_scores_state.js"></script>
<script src="num_status_obj.js"></script>
<script src="multiplier.js"></script>
<script src="mutation_obj.js"></script>
<script src="seeker.js"></script>
<script src="b_cell.js"></script>
<script src="antibody.js"></script>
<script src="random_image_selector.js"></script>
<script src="background_object.js"></script>
<script src="background_edge.js"></script>
<script src="object_with_states.js"></script>
<script src="notification.js"></script>
<!--<script src="fisforformat.min.js"></script>-->
<script src="date.format.js"></script>
<script src="scores/scores.js"></script>
<script src="test.js"></script>
<!-- <script src="rgbcolor.js"></script>
<script src="canvg.js"></script> -->
<script>
//resize the fb canvas
setTimeout(function() {
FB.Canvas.setSize();
}, 1000);
//scores.do_scores();
</script>
<script>
$(document).ready(function() {
$('.theater-enable').click(function() {
$('body').css('background', 'black');
var scoresState = $('#scores-wrap').css('display');
$('.dont-hide-in-theater').siblings().hide();
$('.theater-disable').show();
$('#fork-me-baby').hide();
// center horizontally and vertically
$('.canvas-wrapper').css('position', 'absolute');
$('.canvas-wrapper').css('top', '50%');
$('.canvas-wrapper').css('left', '50%');
// Setting a transform breaks the canvas for some reason.
// These values are half of the width / height of the canvas
$('.canvas-wrapper').css('margin-left', '-350px');
$('.canvas-wrapper').css('margin-top', '-300px');
// Restore
$('#scores-wrap').css('display', scoresState);
});
$('.theater-disable').click(function() {
$('body').css('background', 'white');
var scoresState = $('#scores-wrap').css('display');
$('.dont-hide-in-theater').siblings().show();
$('.theater-disable').hide();
$('#fork-me-baby').show();
// remove added styling
$('.canvas-wrapper').css('position', '');
$('.canvas-wrapper').css('top', '');
$('.canvas-wrapper').css('left', '');
$('.canvas-wrapper').css('margin-left', '');
$('.canvas-wrapper').css('margin-top', '');
$('.canvas-wrapper').css('margin', '0 auto'); // See HTML for canvas-wrapper
// Restore
$('#scores-wrap').css('display', scoresState);
});
$('.theater-enable').click();
var fadeInPage = function() {
var baseDelay = 2500; // Arbitrary number to make sure everything is loaded. If the swiping animation is laggy it looks really bad and is worth waiting longer for a good animation, IMO.
// Fade out text first.
$('#intro-loading-text').delay(baseDelay).animate({ width: '0px'}, 1000);
$("#whole-page-intro-overlay").delay(baseDelay + 1000).animate({ opacity: 0 }, 4000, "swing", function() {
$('#whole-page-intro-overlay').remove();
});
}
// yes this could be shorter... but its efficient and it works so there ya have it.
var count = 0;
var waitAndFadeInPage = function() {
var timeToWait = 200;
window.setTimeout(function() {
if (CHECKED_USER_LOGIN_STATUS || count > (2000 / timeToWait)) { // Don't wait more than 2 seconds
console.log(count);
fadeInPage();
} else {
waitAndFadeInPage();
}
}, timeToWait);
count += 1;
}
if (CHECKED_USER_LOGIN_STATUS) {
fadeInPage();
} else {
waitAndFadeInPage();
}
$('body').css('background', '');
});
</script>
</body>