-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
579 lines (484 loc) · 23.8 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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
<html>
<head>
<title>SFB</title>
<link rel=icon href="sprites/favicon.ico" sizes="16x16" type="image/vnd.microsoft.icon">
<link href='http://fonts.googleapis.com/css?family=Delius+Unicase' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/sfb.css" charset="utf-8">
</head>
<body>
<div id="gameArea">
<canvas id="sfb-game"></canvas>
</div>
<section class="game-menu">
<section class="opening-screen">
<div class="logo">
<img src="css/images/SFB.png" alt="" />
</div>
<button id="single-player-menu"><img src="css/images/singlePlayer.png" alt="" /></button>
<button id="free-for-all-menu"><img src="css/images/freeForAll.png" alt="" /></button>
<button id="team-death-match-menu"><img src="css/images/TEAMdEATHMATCH.png" alt="" /></button>
<button id="open-about-page"><img src="css/images/about.png" alt="" /></button>
</section>
<article class="about-page hidden">
<h1>ABOUT</h1>
<p>
SFB is the brain child of two recent App Academy graduates, Richard Nelson and Bryan Millstein. It is inspired by the desire to entertain and make people laugh. Connect with us on LinkedIn.
</p>
<a href="http://www.linkedin.com/in/richardfnelson" id="rich">Rich</a>
<a href="http://www.linkedin.com/in/bryanmillstein/en" id="bryan">Bryan</a>
<button id="back-to-main-button">Back</button>
</article>
<section class="player-number-selection hidden">
<h1>How many players?</h1>
<ul>
<li class="player-number" data-id="1">ONE (Keyboard Supported)</li>
<li class="player-number" data-id="2">TWO (Keyboard Supported)</li>
<li class="player-number" data-id="3">THREE (Gamepad Controller Required)</li>
<li class="player-number" data-id="4">FOUR (Gamepad Controller Required)</li>
</ul>
</section>
<section class="computer-number-selection hidden">
<h1>How many computer players?</h1>
<ul>
<li class="computer-number" data-id="1">ONE</li>
<li class="computer-number" data-id="2">TWO</li>
<li class="computer-number" data-id="3">THREE</li>
</ul>
</section>
<section class="game-form hidden">
<button class="toggle-players">Change Player Number</button>
<h3>Choose player settings and ready up!</h3>
<h3>Plug in gamepad controller(s) for optimal gaming experience.</h3>
<ul class="player-forms group">
<article class="player-1 group">
<h1>PLAYER ONE</h1>
<ul class="player-1-types" id="types">
<h4>Select Player Type</h4>
<li class="player-type" data-id="1" data-type="Normal">Average Speed and Strength</li>
<li class="player-type" data-id="1" data-type="Fast">Faster but Weaker</li>
<li class="player-type" data-id="1" data-type="Slow">Stronger but Slower</li>
</ul>
<ul class="player-1-farts" id="farts">
<h4>Select Special Attack</h4>
<li class="player-fart" data-id="1" data-type="Bounce">Bouncing</li>
<li class="player-fart" data-id="1" data-type="Mine">Mines</li>
<li class="player-fart" data-id="1" data-type="Flame">Flame</li>
</ul>
<ul class="player-1-teams" id="teams">
<h4>Select Team</h4>
<li class="player-team" data-id="1" data-type="1">Team 1</li>
<li class="player-team" data-id="1" data-type="2">Team 2</li>
</ul>
<button name="ready-up" data-id="1" class="hide-button">Ready Up!</button>
</article>
<article class="player-2 group">
<h1>PLAYER TWO</h1>
<ul class="player-2-types" id="types">
<h4>Select Player Type</h4>
<li class="player-type" data-id="2" data-type="Normal">Average Speed and Strength</li>
<li class="player-type" data-id="2" data-type="Fast">Faster but Weaker</li>
<li class="player-type" data-id="2" data-type="Slow">Stronger but Slower</li>
</ul>
<ul class="player-2-farts" id="farts">
<h4>Select Special Attack</h4>
<li class="player-fart" data-id="2" data-type="Bounce">Bouncing</li>
<li class="player-fart" data-id="2" data-type="Mine">Mine</li>
<li class="player-fart" data-id="2" data-type="Flame">Flame</li>
</ul>
<ul class="player-2-teams" id="teams">
<h4>Select Team</h4>
<li class="player-team" data-id="2" data-type="1">Team 1</li>
<li class="player-team" data-id="2" data-type="2">Team 2</li>
</ul>
<button name="ready-up" data-id="2" class="hide-button">Ready Up!</button>
</article>
<article class="player-3 group">
<h1>PLAYER THREE</h1>
<ul class="player-3-types" id="types">
<h4>Select Player Type</h4>
<li class="player-type" data-id="3" data-type="Normal">Average Speed and Strength</li>
<li class="player-type" data-id="3" data-type="Fast">Faster but Weaker</li>
<li class="player-type" data-id="3" data-type="Slow">Stronger but Slower</li>
</ul>
<ul class="player-3-farts" id="farts">
<h4>Select Special Attack</h4>
<li class="player-fart" data-id="3" data-type="Bounce">Bouncing</li>
<li class="player-fart" data-id="3" data-type="Mine">Mine</li>
<li class="player-fart" data-id="3" data-type="Flame">Flame</li>
</ul>
<ul class="player-3-teams" id="teams">
<h4>Select Team</h4>
<li class="player-team" data-id="3" data-type="1">Team 1</li>
<li class="player-team" data-id="3" data-type="2">Team 2</li>
</ul>
<button name="ready-up" data-id="3" class="hide-button">Ready Up!</button>
</article>
<article class="player-4 group">
<h1>PLAYER FOUR</h1>
<ul class="player-4-types" id="types">
<h4>Select Player Type</h4>
<li class="player-type" data-id="4" data-type="Normal">Average Speed and Strength</li>
<li class="player-type" data-id="4" data-type="Fast">Faster but Weaker</li>
<li class="player-type" data-id="4" data-type="Slow">Stronger but Slower</li>
</ul>
<ul class="player-4-farts" id="farts">
<h4>Select Special Attack</h4>
<li class="player-fart" data-id="4" data-type="Bounce">Bouncing</li>
<li class="player-fart" data-id="4" data-type="Mine">Mine</li>
<li class="player-fart" data-id="4" data-type="Flame">Flame</li>
</ul>
<ul class="player-4-teams" id="teams">
<h4>Select Team</h4>
<li class="player-team" data-id="4" data-type="1">Team 1</li>
<li class="player-team" data-id="4" data-type="2">Team 2</li>
</ul>
<button name="ready-up" data-id="4" class="hide-button">Ready Up!</button>
</article>
</ul>
<article class="controls group">
<h1>Controls</h1>
<ul id="controller-controls">
<h3>Controller</h3>
<li>Left Trigger: Jet Pack</li>
<li>Right Trigger: Jump</li>
<li>'A' Button: Standard Attack</li>
<li>'B' Button: Special Attack</li>
</ul>
<ul id="keyboard-controls-1">
<h3>Keyboard-Player 1</h3>
<li>'A' Button: Move Left</li>
<li>'D' Button: Move Right</li>
<li>'W' Button: Jump</li>
<li>'S' Button: Jet Pack</li>
<li>'Q' Button: Standard Attack</li>
<li>'E' Button: Special Attack</li>
</ul>
<ul id="keyboard-controls-2">
<h3>Keyboard-Player 2</h3>
<li>Left Arrow: Move Left</li>
<li>Right Arrow: Move Right</li>
<li>Up Arrow: Jump</li>
<li>Down Arrow: Jet Pack</li>
<li>'Option' Button: Standard Attack</li>
<li>'Shift' Button: Special Attack</li>
</ul>
</article>
<button name="start-game" class="hide-button">Start Game</button>
</section>
</section>
<section class="closing-screen hidden">
<h1 class="closing-screen-winner"></h1>
<section class="individual-player-stats">
</section>
<button id="replay-game-button">Replay</button>
<button id="new-game-button">Main Menu</button>
</section>
<section class="hidden" id="pause-screen">
<article class="controls group">
<h1>Controls</h1>
<ul id="controller-controls">
<h3>Controller</h3>
<li>Left Trigger: Jet Pack</li>
<li>Right Trigger: Jump</li>
<li>'A' Button: Standard Attack</li>
<li>'B' Button: Special Attack</li>
</ul>
<ul id="keyboard-controls-1">
<h3>Keyboard-Player 1</h3>
<li>'A' Button: Move Left</li>
<li>'D' Button: Move Right</li>
<li>'W' Button: Jump</li>
<li>'S' Button: Jet Pack</li>
<li>'Q' Button: Standard Attack</li>
<li>'E' Button: Special Attack</li>
</ul>
<ul id="keyboard-controls-2">
<h3>Keyboard-Player 2</h3>
<li>Left Arrow: Move Left</li>
<li>Right Arrow: Move Right</li>
<li>Up Arrow: Jump</li>
<li>Down Arrow: Jet Pack</li>
<li>'Option' Button: Standard Attack</li>
<li>'Shift' Button: Special Attack</li>
</ul>
</article>
</section>
<script src="vendor/jquery-2.1.1.js"></script>
<script type="application/javascript" src="vendor/keymaster.js"></script>
<script type="application/javascript" src="lib/utils.js"></script>
<script type="application/javascript" src="lib/gameObject.js"></script>
<script type="application/javascript" src="lib/staticObject.js"></script>
<script type="application/javascript" src="lib/animation.js"></script>
<script type="application/javascript" src="lib/spriteSheet.js"></script>
<script type="application/javascript" src="lib/movingObject.js"></script>
<script type="application/javascript" src="lib/spriteGameObject.js"></script>
<script type="application/javascript" src="lib/animatedObject.js"></script>
<script type="application/javascript" src="lib/gnome.js"></script>
<script type="application/javascript" src="lib/scene.js"></script>
<script type="application/javascript" src="lib/fart.js"></script>
<script type="application/javascript" src="lib/fartBounce.js"></script>
<script type="application/javascript" src="lib/fartFlame.js"></script>
<script type="application/javascript" src="lib/fartMine.js"></script>
<script type="application/javascript" src="lib/bean.js"></script>
<script type="application/javascript" src="lib/fartPack.js"></script>
<script type="application/javascript" src="lib/fartCloud.js"></script>
<script type="application/javascript" src="lib/game.js"></script>
<script type="application/javascript" src="lib/gameView.js"></script>
<script type="application/javascript" src="vendor/fireworks-bundle.js"></script>
<script type="application/javascript" src="lib/exhaustAnimation.js"></script>
<script type="application/javascript" src="lib/fireBall.js"></script>
<script type="application/javascript" src="lib/death.js"></script>
<script type="application/javascript" src="lib/AIgnome.js"></script>
<script type="application/javascript">
(function () {
var canvasEl = document.getElementsByTagName("canvas")[0];
setInterval(function () {
// STORE ARRAY OF GAMEPADS IN GLOBAL OBJECT
window.gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : []);
}, 20)
canvasEl.width = SFB.Game.DIM_X;
canvasEl.height = SFB.Game.DIM_Y;
var ctx = canvasEl.getContext("2d");
var that = this;
var startGame = function() {
var body = $("body");
body[0].classList.add('white-body');
if (that.game.spritesStillLoading > 0) {
setTimeout(startGame(), 100)
} else {
new SFB.GameView(that.game, ctx).start();
}
};
/* Store the players and their attrs in an object that will then be passed to the new game*/
PLAYERS = {};
TEAMS = {};
READYPLAYERS = [];
/* EVENT LISTENERS */
/* Single Player Menu */
var addSinglePlayerMenu = function () {
/* Handle team number designation */
var openingScreen = document.getElementsByClassName('opening-screen'),
computerNumberScreen = document.getElementsByClassName('computer-number-selection');
openingScreen[0].classList.add('hidden');
computerNumberScreen[0].classList.remove('hidden');
showTeams = false;
GAMEMODE = 'Single';
}
var menuButton = document.getElementById('single-player-menu');
menuButton.addEventListener('click', addSinglePlayerMenu);
/* Free For All Menu */
var addFreeForAllMenu = function () {
/* Handle team number designation */
var openingScreen = document.getElementsByClassName('opening-screen'),
multiplayerScreen = document.getElementsByClassName('player-number-selection');
openingScreen[0].classList.add('hidden');
multiplayerScreen[0].classList.remove('hidden');
showTeams = false;
GAMEMODE = 'Free';
}
var menuButton = document.getElementById('free-for-all-menu');
menuButton.addEventListener('click', addFreeForAllMenu);
/* Team Deathmatch Menu */
var addTeamDeathMatchMenu = function () {
var openingScreen = document.getElementsByClassName('opening-screen'),
multiplayerScreen = document.getElementsByClassName('player-number-selection');
openingScreen[0].classList.add('hidden');
multiplayerScreen[0].classList.remove('hidden');
showTeams = true;
GAMEMODE = 'Team';
}
var menuButton = document.getElementById('team-death-match-menu');
menuButton.addEventListener('click', addTeamDeathMatchMenu);
/* About Page */
var addAboutPage = function () {
var openingScreen = document.getElementsByClassName('opening-screen'),
aboutPage = document.getElementsByClassName('about-page');
openingScreen[0].classList.add('hidden');
aboutPage[0].classList.remove('hidden');
}
var aboutButton = document.getElementById('open-about-page');
aboutButton.addEventListener('click', addAboutPage);
/* Back to Main Menu */
var backToMain = function () {
var openingScreen = document.getElementsByClassName('opening-screen'),
aboutPage = document.getElementsByClassName('about-page');
openingScreen[0].classList.remove('hidden');
aboutPage[0].classList.add('hidden');
}
var backToMainButton = document.getElementById('back-to-main-button');
backToMainButton.addEventListener('click', backToMain);
/* Get Computer Player Number*/
var addComputers = function (event) {
var target = $(event.currentTarget),
menu = document.getElementsByClassName('computer-number-selection'),
attrsMenu = document.getElementsByClassName('game-form');
COMPUTERS = target.data('id');
menu[0].classList.add('hidden');
attrsMenu[0].classList.remove('hidden');
var playerChoices = document.getElementsByClassName('player-1');
PLAYERS[1] = { attrs: {} };
playerChoices[0].classList.add('display-players');
var displayTeam = document.getElementsByClassName('player-1-teams');
displayTeam[0].classList.add('hidden');
PLAYERS[1]['attrs']['playerTeam'] = 1;
};
var computerNumbers = document.getElementsByClassName('computer-number');
for(var i = 0; i < computerNumbers.length; i ++) {
computerNumbers[i].addEventListener('click', addComputers);
}
/* Get Player Number*/
var addPlayers = function (event) {
var target = $(event.currentTarget),
players = target.data('id'),
menu = document.getElementsByClassName('player-number-selection'),
attrsMenu = document.getElementsByClassName('game-form');
menu[0].classList.add('hidden');
attrsMenu[0].classList.remove('hidden');
for(var i = 1; i <= players; i ++) {
var playerChoices = document.getElementsByClassName('player-' + i);
PLAYERS[i] = { attrs: {} };
playerChoices[0].classList.add('display-players');
/* If game mode is free for all then hide team selection and assign each player to a different team.*/
if (!showTeams) {
var displayTeam = document.getElementsByClassName('player-' + i + '-teams');
displayTeam[0].classList.add('hidden');
PLAYERS[i]['attrs']['playerTeam'] = i;
}
};
};
var playerNumbers = document.getElementsByClassName('player-number');
for(var i = 0; i < playerNumbers.length; i ++) {
playerNumbers[i].addEventListener('click', addPlayers);
}
/* Change Computer Player Number */
var toggleComputers = function(options) {
menu = document.getElementsByClassName('computer-number-selection'),
attrsMenu = document.getElementsByClassName('game-form');
menu[0].classList.remove('hidden');
attrsMenu[0].classList.add('hidden');
};
/* Change Player Number */
var togglePlayers = function(options) {
menu = document.getElementsByClassName('player-number-selection'),
attrsMenu = document.getElementsByClassName('game-form');
menu[0].classList.remove('hidden');
attrsMenu[0].classList.add('hidden');
};
var changePlayerButton = document.getElementsByClassName('toggle-players');
changePlayerButton[0].addEventListener('click', function () {
if (GAMEMODE === "Single") {
toggleComputers();
} else {
togglePlayers();
}
});
/* Get player speed/health setting */
var addPlayersType = function (event) {
var target = $(event.currentTarget),
player = target.data('id'),
playerType = target.data('type');
var playerTypes = $( "ul.player-" + player + "-types > li");
for(var j = 0; j < playerTypes.length; j ++) {
playerTypes[j].classList.remove('highlight-selection');
}
target[0].classList.add('highlight-selection');
PLAYERS[player]['attrs']['playerType'] = playerType;
if (Object.keys(PLAYERS[player]['attrs']).length === 3) {
var readyButton = $( "article.player-" + player + "> button");
readyButton[0].classList.remove('hide-button');
}
}
var playersType = document.getElementsByClassName('player-type');
for(var i = 0; i < playersType.length; i ++) {
playersType[i].addEventListener('click', addPlayersType);
}
/* Get player special fart */
var addPlayersFart = function (event) {
var target = $(event.currentTarget),
player = target.data('id'),
playerFart = target.data('type');
var playerFarts = $( "ul.player-" + player + "-farts > li");
for(var j = 0; j < playerFarts.length; j ++) {
playerFarts[j].classList.remove('highlight-selection');
}
target[0].classList.add('highlight-selection');
PLAYERS[player]['attrs']['fart'] = playerFart;
if (Object.keys(PLAYERS[player]['attrs']).length === 3) {
var readyButton = $( "article.player-" + player + "> button");
readyButton[0].classList.remove('hide-button');
}
}
var playersFart = document.getElementsByClassName('player-fart');
for(var i = 0; i < playersFart.length; i ++) {
playersFart[i].addEventListener('click', addPlayersFart);
}
/* Get Player Team */
var addPlayersTeam = function (event) {
var target = $(event.currentTarget),
player = target.data('id'),
playerTeam = target.data('type');
var playerTeams = $( "ul.player-" + player + "-teams > li");
for(var j = 0; j < playerTeams.length; j ++) {
playerTeams[j].classList.remove('highlight-selection');
}
target[0].classList.add('highlight-selection');
PLAYERS[player]['attrs']['playerTeam'] = playerTeam;
if (Object.keys(PLAYERS[player]['attrs']).length === 3) {
var readyButton = $( "article.player-" + player + "> button");
readyButton[0].classList.remove('hide-button');
}
}
var playersTeam = document.getElementsByClassName('player-team');
for(var i = 0; i < playersTeam.length; i ++) {
playersTeam[i].addEventListener('click', addPlayersTeam);
}
/* Ready up */
var readyPlayer = function() {
var target = $(event.currentTarget),
playerNumber = target.data('id'),
player = document.getElementsByClassName('player-' + playerNumber)[0];
player.classList.add('player-ready');
READYPLAYERS.push(player);
if (Object.keys(PLAYERS).length === READYPLAYERS.length) {
var startButton = document.getElementsByName('start-game');
startButton[0].classList.remove('hide-button');
startButton[0].classList.add('start-game');
}
};
var readyButton = document.getElementsByName('ready-up');
for(var i = 0; i < readyButton.length; i ++) {
readyButton[i].addEventListener('click', readyPlayer);
}
/* Start Game */
var readyGame = function(options) {
var numPlayers = Object.keys(PLAYERS).length
if (numPlayers === READYPLAYERS.length) {
game = new SFB.Game(numPlayers);
var menu = document.getElementsByClassName('game-menu')[0];
menu.classList.add('hide-menu');
startGame();
var body = $("body");
body[0].classList.add('white-body');
}
};
var startButton = document.getElementsByName('start-game');
startButton[0].addEventListener('click', readyGame);
/* Return To Main Menu After Ending*/
var loadMainMenu = function () {
location.reload();
}
var mainMenuReturn = document.getElementById('new-game-button');
mainMenuReturn.addEventListener('click', loadMainMenu);
/* Restart Game After Ending*/
var restartGame = function () {
var body = $("body");
$('#gameArea')[0].classList.remove('hidden');
$('.closing-screen')[0].classList.add('hidden');
readyGame();
}
var replayGameButton = document.getElementById('replay-game-button');
replayGameButton.addEventListener('click', restartGame);
})();
</script>
</body>
</html>