-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
7095 lines (6480 loc) · 360 KB
/
index.php
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
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
* Author: Chad Cromwell
* Date: 2019-03-25
* Description: A tower defense game where a user purchases towers to defend their windmill from attacking ants
* Music: Eric Skiff - Chibi Ninja, Jumpshot, Arpanauts, We're the Resistors, Undercocked (underunderclocked mix) - Resistor Anthems - Available at http://EricSkiff.com/music
* Functions:
* keyboard(value) function - Handles keyboard input
* playDeflectSound() function - Plays a deflect sound from the pool of deflect Audio objects
* playHitSound() function - Plays a hit sound from the pool of ant hit Audio objects
* playKillSound() function - Plays a hit sound from the pool of ant kill Audio objects
* playWindmillSound() function - Plays a hit sound from the pool of windmill hit Audio objects
* playSlingshotSound() function - Plays a hit sound from the pool of slingshot Audio objects
* playHammerSound() function - Plays a hit sound from the pool of hammer Audio objects
* playBugSpraySound() function - Plays a hit sound from the pool of bug spray Audio objects
* playMagnifyingGlassSound() function - Plays a hit sound from the pool of magnifying glass Audio objects
* playCannonSound() function - Plays a hit sound from the pool of cannon Audio objects
* playHoneySound() function - Plays a hit sound from the pool of honey Audio objects
* muteUnmuteSoundEffects() function - Mutes or unmutes the sound effects
* playPauseMusic() function - Plays or pauses the music
* playNextSong() function - Plays through the background music on shuffle, will not repeat the same song twice in a row
* updateToolTipPosition() function - Updates the position of the tooltip to keep in within the display no matter where the user puts their mouse
* updateToolTip(string) function - Accepts a string, updates the tooltip text and the size of the box
* showToolTip() function - Shows the tooltip
* hideToolTip() function - Hides the tooltip
* initialize() function - Initializes the game buttons
* updatePathText() function - Updates the path upgrade buttons text depending on what the user has unlocked
* updateTowerButtonCostText() function - Updates the cost of each tower button (depends on the difficulty level chosen)
* target(string) function - Accepts a string and sets the currently selected tower's target priority to the string. "first", "last", "strongest", "closest"
* hideInfoBar() function - Hides the info bar
* showInfoBar() function - Shows the info bar
* resetInfoBar() function - Resets the info bar to default
* updateInfoBar() function - Updates the info bar
* logIn() function - Sets booleans to show user is logged in and it is not a guest, updates the tower menu info and enables debugging mode if admin user (userId 1)
* logOut() function - Sets booleans to show user is logged out, updates player object to be a guest, clears cookies, restarts game
* setWindmill(string) function - Sets the windmill's material. "wood", "stone", "concrete", "steel"
* hidePlayScreen() function - Hides the play screen
* showPlayScreen() function - Shows the play screen
* hideMainMenu() function - Hides the main menu
* showMainMenu() function - Shows the main menu
* hideLoggedInMenu() function - Hides the logged in menu
* showLoggedInMenu() function - Shows the logged in menu
* updateWindmillButtons() function - Updates the windmill buttons. Enables those they user has unlocked, disables those they have not
* hideWindmillMenu() function - Hide the windmill menu
* showWindmillMenu() function - Show the windmill menu
* hideTowersMenu() function - Hide the towers menu
* showTowersMenu() function - Shows the towers menu
* hideLevelMenu() function - Hide the level menu
* showLevelMenu() function - Shows the level menu
* hideDifficultyMenu() function - Hides the difficulty menu
* showDifficultyMenu() function - Shows the difficulty menu
* setLevel() function - Sets/load proper level
* quitGame() function - Quits the game, updates the player stats to the database, resets, and goes back to main menu
* hideTowerBarButtons() function - Hides the tower bar buttons
* showTowerBarButtons() function - Show the tower bar buttons
* resumeGame() function - Updates the play/pause button to reflect game is playing
* pauseGame() function - Updates the play/pause button to reflect game is paused
* overlayMenuClick() function - Handles when user clicks on the menu button
* showOverlayMenu() function - Shows the overlay menu
* hideOverlayMenu() function - Hides the overlay menu
* hideSellButton() function - Hides the sell button
* showSellButton() function - Shows the sell button
* changeSpeed() function - Change the game speed
* startGame() function - Starts the game
* updateWindmill() function - Update the windmill damage textures based on hp
* updateInfoText() function - Updates the information text along the top of the screen to reflect stats
* updateTowerMenuTiers() function - Updates the tower menu tiers to be used on the tower menu screen. Ex. 1/4 tiers unlocked.
* setSize() function - Sets the level sprite sizes
* lostGame() function - When the player loses, display the loss screen
* wonGame() function - When the player wins, display the win screen
* hideWinMenu() function - Hides the win menu
* showWinMenu() function - Shows the win menu
* showFinalWinMenu() function - Shows the win menu without the continue button because the windmill has been destroyed or beat last wave
* resetGame() function - Resets variables so game can start again
* waveWon() function - Called when wave is over and gets ready for next
* addAnts(array, numAnts, type, armored, regenerative, cloaked, parent) function - Adds ants to passed array and to passed stage
* addSlingshot() function - Adds a slingshot tower
* addHammer() function - Adds a hammer tower
* addBugSpray() function - Adds a bug spray tower
* addMagnifyingGlass() function - Adds a magnifying glass tower
* addCannon() function - Adds a cannon tower
* addHoney() function - Adds a honey tower
* nextWave() function - Loads and starts the next wave
* sellTower(index) function - Accepts an index and sells the corresponding tower
* enableTowerInteraction() function - Enables interaction and buttonMode of all towers
* disableTowerInteraction() function - Disables interaction and buttonMode of all towers
* playPause() function - Pauses and resumes the game
* addBrown(int) function - Accepts an int and adds that many brown ants to the waveContainer
* addBrownA(int) function - Accepts an int and adds that many armoured brown ants to the waveContainer
* addBrownR(int) function - Accepts an int and adds that many regenerative brown ants to the waveContainer
* addBrownC(int) function - Accepts an int and adds that many cloaked brown ants to the waveContainer
* addBlue(int) function - Accepts an int and adds that many blue ants to the waveContainer
* addBlueA(int) function - Accepts an int and adds that many armoured blue ants to the waveContainer
* addBlueR(int) function - Accepts an int and adds that many regenerative blue ants to the waveContainer
* addBlueC(int) function - Accepts an int and adds that many cloaked blue ants to the waveContainer
* addGreen(int) function - Accepts an int and adds that many green ants to the waveContainer
* addGreenA(int) function - Accepts an int and adds that many armoured green ants to the waveContainer
* addGreenR(int) function - Accepts an int and adds that many regenerative green ants to the waveContainer
* addGreenCloaked(int) function - Accepts an int and adds that many cloaked green ants to the waveContainer
* addYellow(int) function - Accepts an int and adds that many yellow ants to the waveContainer
* addYellowA(int) function - Accepts an int and adds that many armoured yellow ants to the waveContainer
* addYellowR(int) function - Accepts an int and adds that many regenerative yellow ants to the waveContainer
* addYellowC(int) function - Accepts an int and adds that many cloaked yellow ants to the waveContainer
* addPurple(int) function - Accepts an int and adds that many purple ants to the waveContainer
* addPurpleA(int) function - Accepts an int and adds that many armoured purple ants to the waveContainer
* addPurpleR(int) function - Accepts an int and adds that many regenerative purple ants to the waveContainer
* addPurpleC(int) function - Accepts an int and adds that many cloaked purple ants to the waveContainer
* addBlack(int) function - Accepts an int and adds that many black ants to the waveContainer
* addBlackA(int) function - Accepts an int and adds that many armoured black ants to the waveContainer
* addBlackR(int) function - Accepts an int and adds that many regenerative black ants to the waveContainer
* addBlackC(int) function - Accepts an int and adds that many cloaked black ants to the waveContainer
* addWhite(int) function - Accepts an int and adds that many white ants to the waveContainer
* addWhiteA(int) function - Accepts an int and adds that many armoured white ants to the waveContainer
* addWhiteR(int) function - Accepts an int and adds that many regenerative white ants to the waveContainer
* addWhiteC(int) function - Accepts an int and adds that many cloaked white ants to the waveContainer
* addRed(int) function - Accepts an int and adds that many red ants to the waveContainer
* addRedA(int) function - Accepts an int and adds that many armoured red ants to the waveContainer
* addRedR(int) function - Accepts an int and adds that many regenerative red ants to the waveContainer
* addRedC(int) function - Accepts an int and adds that many cloaked red ants to the waveContainer
* addBeetle(int) function - Accepts an int and adds that many beetles to the waveContainer
* addBeetleA(int) function - Accepts an int and adds that many armoured beetles to the waveContainer
* addBeetleC(int) function - Accepts an int and adds that many cloaked beetles to the waveContainer
* addGreenLeaf(int) function - Accepts an int and adds that many green leaves to the waveContainer
* addStyrofoamCup(int) function - Accepts an int and adds that many styrofoam cups to the waveContainer
* addSodaCan(int) function - Accepts an int and adds that many soda cans to the waveContainer
* addRock(int) function - Accepts an int and adds that many rocks to the waveContainer
* waveMaker(int) function - Accepts a wave number and adds respective ants to the current wave.
* shuffleArray(array) function - Shuffle the passed array
* rememberMe() function - Sets up cookie with unique auth token, adds auth token to database so user can stay logged in securely
* randomToken($length = 20) function - Generate a random auth token and return it to selector variable
* updatePlayerStats() function - Updates the player stats to the database
* addPlayer() function - Adds a player to the database
* update() function - Updates ants
* login() function - Called when user attempts to log in in login modal
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Ants!</title>
</head>
<script src="pixi/pixi.min.js"></script>
<body onresize="resize()" style="background-color: black">
<link rel="stylesheet" type="text/css" href="css/style.css">
<div id="loginpopup" class="modal">
<form class="modal-content animate" id="loginform" onsubmit="login()">
<div class="topbar" id="topbar">
<span onclick="document.getElementById('loginpopup').style.display='none'" class="close" title="Close Modal">×</span>
</div>
<div class="pta" id="pta">
"Please try again."
</div>
<div class="container">
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" id="email" name="email" required>
<label for="password"><b>Password</b></label>
<input type="password" placeholder="Enter Password" id="password" name="password" required>
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember" id="remember"> Remember me
</label>
</div>
<div class="container" style="background-color:#f1f1f1">
<button type="button" onclick="document.getElementById('loginpopup').style.display='none'" class="cancelbutton">Cancel</button>
<span class="password">Forgot <a href="#">password?</a></span>
</div>
</form>
</div>
<div id="signuppopup" class="modal">
<form class="modal-content animate" id="signupform" onsubmit="addPlayer()">
<div class="topbar" id="signuptopbar">
<span onclick="document.getElementById('signuppopup').style.display='none'" class="close" title="Close Modal">×</span>
</div>
<div class="pta" id="signupaccountexists">
"Account already exists."
</div>
<div class="container">
<label for="username"><b>Username</b></label>
<input type="text" placeholder="Enter Username" id="signupusername" name="email" required>
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" id="signupemail" name="email" required>
<label for="password"><b>Password</b></label>
<input type="password" placeholder="Enter Password" id="signuppassword" name="password" required>
<button type="submit">Sign Up</button>
</div>
<div class="container" style="background-color:#f1f1f1">
<button type="button" onclick="document.getElementById('signuppopup').style.display='none'" class="cancelbutton">Cancel</button>
</div>
</form>
</div>
<script src="js/functions.js"></script>
<script src="js/Player.js"></script>
<script src="js/variables.js"></script>
<script src="js/Ant.js"></script>
<script src="js/Tower.js"></script>
<script src="js/Projectile.js"></script>
<script>
//Add containers to stage
app.stage.addChild(levelContainerBG); //Level background container (holds ground image)
app.stage.addChild(waveContainer); //Wave container (holds ants)
app.stage.addChild(towersContainer); //Towers container (holds towers)
app.stage.addChild(projectileContainer); //Projectile container (holds projectiles)
app.stage.addChild(windmillContainer); //Windmill container (holds the windmill)
app.stage.addChild(levelContainerFG); //Level foreground container (holds trees)
app.stage.addChild(menuContainer); //Menu container (holds menu sprites)
app.stage.addChild(leftBarContainer); //Left bar container (holds the left bar)
app.stage.addChild(leftBarTowerSpritesContainer); //Left bar tower sprites container (holds the tower images for buttons)
app.stage.addChild(topBarContainer); //Top bar container (holds the top info bar)
app.stage.addChild(infoBarContainer); //Top info bar (holds string of info)
app.stage.addChild(overlayMenuContainer); //Overlay menu container (holds the overlay menu)
menuContainer.addChild(percentageText); //Add the loading percentage text to menuContainer to show while game is loading
app.stage.addChild(mediaContainer); //Add media container (holds buttons for controlling sound)
app.stage.addChild(tooltipContainer); //Add tooltip container (holds tooltip)
//Create info bar background
topBarContainerBG = new PIXI.Graphics(); //Create top bar container graphic object for background
topBarContainerBG.beginFill(0xFFFFFF); //Fill white
topBarContainerBG.lineStyle(2, 0x000000); //Black stroke
topBarContainerBG.drawRect(appWidth-(appWidth*resizeFactor), 0, appWidth*resizeFactor, appHeight-(appHeight*resizeFactor)); //Draw it
topBarContainer.addChild(topBarContainerBG); //Add to top bar container
//Tower bar background
leftBarContainerBG = new PIXI.Graphics(); //Create left bar container graphic object for background
leftBarContainerBG.beginFill(0xFFFFFF); //Fill white
leftBarContainerBG.lineStyle(2, 0x000000); //Black stroke
leftBarContainerBG.drawRect(0, 0, appWidth-(appWidth*resizeFactor), appHeight); //Draw it
leftBarContainer.addChild(leftBarContainerBG); //Add to left bar container
leftBarContainer.interactive = true;
leftBarContainer.on("mouseout", () => {
hideToolTip();
});
//Make containers invisible for menu state
levelContainerBG.visible = false; //Hide it
waveContainer.visible = false; //Hide it
towersContainer.visible = false; //Hide it
projectileContainer.visible = false; //Hide it
windmillContainer.visible = false; //Hide it
levelContainerFG.visible = false; //Hide it
leftBarContainer.visible = false; //Hide it
infoBarContainer.visible = false; //Hide it
leftBarTowerSpritesContainer.visible = false; //Hide it
topBarContainer.visible = false; //Hide it
mediaContainer.visible = true; //Show it
tooltipContainer.visible = false; //Hide it
currentTower = new Tower(1, {x: 0, y: 0}, null); //Assign default currentTower to avoid exceptions below. Never really used in game.
//keyboard(value) function - Handles keyboard input
function keyboard(value) {
let key = {}; //Key object
key.value = value; //Capture value
key.isDown = false; //Initialize as not being pressed
key.isUp = true; //Initialize as not being pressed
key.press = undefined; //Initialize as not being pressed
key.release = undefined; //Initialize as not being pressed
//When button is pressed down
key.downHandler = event => {
if (event.key === key.value) {
//If the key is up and has just been pressed, call key.press()
if (key.isUp && key.press) key.press();
key.isDown = true; //Key is down
key.isUp = false; //Key is not up
//event.preventDefault(); //Prevent default behaviour
}
};
//When button is released
key.upHandler = event => {
if (event.key === key.value) {
//If the key is down and has just been released, call key.release()
if (key.isDown && key.release) key.release();
key.isDown = false; //Key is not down
key.isUp = true; //Key is up
//event.preventDefault(); //Prevent default behaviour
}
};
//Create listeners
const downListener = key.downHandler.bind(key); //Key down listener
const upListener = key.upHandler.bind(key); //Key up listener
//Add event listeners to "keydown" events
window.addEventListener(
"keydown", downListener, false
);
//Add event listeners to "keyup" events
window.addEventListener(
"keyup", upListener, false
);
//Detach event listeners
key.unsubscribe = () => {
window.removeEventListener("keydown", downListener);
window.removeEventListener("keyup", upListener);
};
return key; //Return the key
}
//****HANDLE KEYBOARD INPUT---------------------------------------------------------------------------------------------
//If SPACEBAR is pressed/released
let key = keyboard(" ");
let keyInputEnabled = false;
//When pressed, do nothing
key.press = () => {
};
//When released
key.release = () => {
//If playing, game is tarted, and wave is happening
if(playing && startGameBool && !waveWonBool) {
//Unselect all towers
for(let i = 0; i < towers.length; i++) {
towers[i].selected = false; //Deselct towers
}
hideInfoBar(); //Hide info bar
playPause(); //Play or pause
}
//If wave is over
else if(waveWonBool) {
nextWave(); //Start next wave
}
//If the overlay menu is being shown, hide it
if(overlayMenu) {
hideOverlayMenu(); //Hide the overlay menu
}
};
//If + is pressed
key = keyboard("+");
key.release = () => {
//If key input is enabled
if(keyInputEnabled) {
if (debugMode) {
player.gold += 1000; //Increase gold by 1000
}
}
};
//If = is pressed
key = keyboard("=");
key.release = () => {
//If key input is enabled
if(keyInputEnabled) {
if (debugMode) {
windmillSprite.hp += 100; //Increase hp by 100
}
}
};
//If m is pressed
key = keyboard("m");
key.release = () => {
//If key input is enabled
if(keyInputEnabled) {
playPauseMusic(); //Play or pause the music
}
};
//If s is pressed
key = keyboard("s");
key.press = () => {
//If key input is enabled
if(keyInputEnabled) {
muteUnmuteSoundEffects(); //Mute or unmute the sound effects
}
};
//****AUDIO-------------------------------------------------------------------------------------------------------------
//Initialize music and sound effects
musicArray.push(new Audio("Assets/Sounds/bg1.mp4")); //Load background music track 1
musicArray[0].volume = musicVolume; //Set volume
musicArray.push(new Audio("Assets/Sounds/bg2.mp4")); //Load background music track 2
musicArray[1].volume = musicVolume; //Set volume
musicArray.push(new Audio("Assets/Sounds/bg3.mp4")); //Load background music track 3
musicArray[2].volume = musicVolume; //Set volume
musicArray.push(new Audio("Assets/Sounds/bg4.mp4")); //Load background music track 4
musicArray[3].volume = musicVolume; //Set volume
musicArray.push(new Audio("Assets/Sounds/bg5.mp4")); //Load background music track 5
musicArray[4].volume = musicVolume; //Set volume
let lastRand = Math.floor(Math.random()*Math.floor(5)); //Generate random int for picking music track
music = musicArray[lastRand]; //Assign randomly chosen song to music variable
//Add 4 Audio objects for each hit sound effect
for(let i = 0; i < 4; i++) {
armoredDeflectSoundArray.push(new Audio("Assets/Sounds/armoredDeflect.wav")); //Add new deflect Audio object
armoredDeflectSoundArray[i].volume = armoredDeflectVolume; //Set volume
hitAntSoundArray.push(new Audio("Assets/Sounds/antHit.wav")); //Add new ant hit Audio object
hitAntSoundArray[i].volume = hitAntVolume; //Set volume
killAntSoundArray.push(new Audio("Assets/Sounds/antKill.wav")); //Add new ant kill Audio object
killAntSoundArray[i].volume = killAntVolume; //Set volume
hitWindmillSoundArray.push(new Audio("Assets/Sounds/windmillHit.wav")); //Add new hit windmill sound
hitWindmillSoundArray[i].volume = hitWindmillVolume; //Set volume
}
//Add 2 Audio objects for each tower sound effect
for(let i = 0; i < 2; i++) {
slingshotSoundArray.push(new Audio("Assets/Sounds/slingshot.wav")); //Add new slingshot Audio object
slingshotSoundArray[i].volume = slingshotVolume;
hammerSoundArray.push(new Audio("Assets/Sounds/hammer.wav")); //Add new hammer Audio object
hammerSoundArray[i].volume = hammerVolume;
bugSpraySoundArray.push(new Audio("Assets/Sounds/bugSpray.wav")); //Add new bug spray Audio object
bugSpraySoundArray[i].volume = bugSprayVolume;
magnifyingGlassSoundArray.push(new Audio("Assets/Sounds/magnifyingGlass.wav")); //Add new magnifying glass Audio object
magnifyingGlassSoundArray[i].volume = magnifyingGlassVolume;
cannonSoundArray.push(new Audio("Assets/Sounds/cannon.wav")); //Add new cannon Audio object
cannonSoundArray[i].volume = cannonVolume;
honeySoundArray.push(new Audio("Assets/Sounds/honey.wav")); //Add new honey Audio object
honeySoundArray[i].volume = honeyVolume;
}
//playDeflectSound() function - Plays a deflect sound from the pool of deflect Audio objects
function playDeflectSound() {
//If sound effects can be played
if(playSoundEffects) {
//Iterate through pool of Audio objects
for(let i = 0; i < armoredDeflectSoundArray.length; i++) {
//If the Audio object is paused
if(armoredDeflectSoundArray[i].paused) {
armoredDeflectSoundArray[i].play(); //Play it
break;
}
}
}
}
//playHitSound() function - Plays a hit sound from the pool of ant hit Audio objects
function playHitSound() {
//If sound effects can be played
if(playSoundEffects) {
//Iterate through pool of Audio objects
for(let i = 0; i < hitAntSoundArray.length; i++) {
//If the Audio object is paused
if(hitAntSoundArray[i].paused) {
hitAntSoundArray[i].play(); //Play it
break;
}
}
}
}
//playKillSound() function - Plays a hit sound from the pool of ant kill Audio objects
function playKillSound() {
//If sound effects can be played
if(playSoundEffects) {
//Iterate through pool of Audio objects
for(let i = 0; i < killAntSoundArray.length; i++) {
//If the Audio object is paused
if(killAntSoundArray[i].paused) {
killAntSoundArray[i].play(); //Play it
break;
}
}
}
}
//playWindmillSound() function - Plays a hit sound from the pool of windmill hit Audio objects
function playWindmillSound() {
//If sound effects can be played
if(playSoundEffects) {
//Iterate through pool of Audio objects
for(let i = 0; i < hitWindmillSoundArray.length; i++) {
//If the Audio object is paused
if(hitWindmillSoundArray[i].paused) {
hitWindmillSoundArray[i].play(); //Play it
break;
}
}
}
}
//playSlingshotSound() function - Plays a hit sound from the pool of slingshot Audio objects
function playSlingshotSound() {
//If sound effects can be played
if(playSoundEffects) {
//Iterate through pool of Audio objects
for(let i = 0; i < slingshotSoundArray.length; i++) {
//If the Audio object is paused
if(slingshotSoundArray[i].paused) {
slingshotSoundArray[i].play(); //Play it
break;
}
}
}
}
//playHammerSound() function - Plays a hit sound from the pool of hammer Audio objects
function playHammerSound() {
//If sound effects can be played
if(playSoundEffects) {
//Iterate through pool of Audio objects
for(let i = 0; i < hammerSoundArray.length; i++) {
//If the Audio object is paused
if(hammerSoundArray[i].paused) {
hammerSoundArray[i].play(); //Play it
break;
}
}
}
}
//playBugSpraySound() function - Plays a hit sound from the pool of bug spray Audio objects
function playBugSpraySound() {
//If sound effects can be played
if(playSoundEffects) {
//Iterate through pool of Audio objects
for(let i = 0; i < bugSpraySoundArray.length; i++) {
//If the Audio object is paused
if(bugSpraySoundArray[i].paused) {
bugSpraySoundArray[i].play(); //Play it
break;
}
}
}
}
//playMagnifyingGlassSound() function - Plays a hit sound from the pool of magnifying glass Audio objects
function playMagnifyingGlassSound() {
//If sound effects can be played
if(playSoundEffects) {
//Iterate through pool of Audio objects
for(let i = 0; i < magnifyingGlassSoundArray.length; i++) {
//If the Audio object is paused
if(magnifyingGlassSoundArray[i].paused) {
magnifyingGlassSoundArray[i].play(); //Play it
break;
}
}
}
}
//playCannonSound() function - Plays a hit sound from the pool of cannon Audio objects
function playCannonSound() {
//If sound effects can be played
if(playSoundEffects) {
for (let i = 0; i < cannonSoundArray.length; i++) {
//If the Audio object is paused
if (cannonSoundArray[i].paused) {
cannonSoundArray[i].play(); //Play it
break;
}
}
}
}
//playHoneySound() function - Plays a hit sound from the pool of honey Audio objects
function playHoneySound() {
//If sound effects can be played
if(playSoundEffects) {
for (let i = 0; i < honeySoundArray.length; i++) {
//If the Audio object is paused
if (honeySoundArray[i].paused) {
honeySoundArray[i].play(); //Play it
break;
}
}
}
}
//muteUnmuteSoundEffects() function - Mutes or unmutes the sound effects
function muteUnmuteSoundEffects() {
//If sound effects are playing
if(playSoundEffects) {
playSoundEffects = false; //Don't play them
sfxOnSprite.visible = false; //Show on sprite
sfxOffSprite.visible = true; //Hide off sprite
}
//Else, they aren't playing
else {
playSoundEffects = true; //Play them
sfxOnSprite.visible = true; //Hide on sprite
sfxOffSprite.visible = false; //Show off sprite
}
}
//playPauseMusic() function - Plays or pauses the music
function playPauseMusic() {
//If the music is paused, play it
if(music.paused) {
playMusic = true; //Music should be playing
music.play();
musicOnSprite.visible = true;
musicOffSprite.visible = false;
}
//Else, if the music is playing, pause it
else {
playMusic = false; //Music should be paused
music.pause();
musicOnSprite.visible = false;
musicOffSprite.visible = true;
}
}
//playNextSong() function - Plays through the background music on shuffle, will not repeat the same song twice in a row
function playNextSong() {
//If the music should be playing
if(playMusic) {
//If the background music has finished playing
if (music.paused) {
let newRand = Math.floor(Math.random() * Math.floor(5)); //Generate a new random int
//If the new random int matches the last one, that means we need to try again to find a new track
if (lastRand === newRand) {
playNextSong(); //Recursively call this function to try again
}
//Else, the new random int doesn't match the last one, we found a new track to play
else {
music = musicArray[newRand]; //Update music to new track
music.play(); //Play it
lastRand = newRand; //Update last random int with this current random int
}
}
}
}
//updateToolTipPosition() function - Updates the position of the tooltip to keep in within the display no matter where the user puts their mouse
function updateToolTipPosition() {
tooltipContainer.position.set(mousePos.x+10, mousePos.y+10);
if(mousePos.x > (appWidth/2)) {
tooltipContainer.x = mousePos.x-tooltipContainer.width-10;
}
if(mousePos.x < (appWidth/2)) {
tooltipContainer.x = mousePos.x+10;
}
if(mousePos.y > (appHeight/2)) {
tooltipContainer.y = mousePos.y-tooltipContainer.height-10;
}
if(mousePos.y < (appHeight/2)) {
tooltipContainer.y = mousePos.y+10;
}
}
//updateToolTip(string) function - Accepts a string, updates the tooltip text and the size of the box
function updateToolTip(string) {
tooltipText.text = string;
tooltipBox.clear();
tooltipBox.beginFill(0x000000, tooltipAlpha);
tooltipBox.drawRect(0, 0, tooltipText.width, tooltipText.height);
}
//showToolTip() function - Shows the tooltip
function showToolTip() {
tooltipContainer.visible = true;
}
//hideToolTip() function - Hides the tooltip
function hideToolTip() {
tooltipContainer.visible = false;
}
//initialize() function - Initializes the game buttons
function initialize() {
menuContainer.removeChild(percentageText); //Remove the loading percentage text
tooltipText = new PIXI.Text("tooltip", {fontFamily: "Arial", fontSize: 24, fill: 0xFFFFFF, align: "center"}); //Create tooltip text
tooltipBox = new PIXI.Graphics();
tooltipBox.beginFill(0x000000, tooltipAlpha);
tooltipBox.drawRect(0,0,tooltipText.width, tooltipText.height);
//tooltipBox.position.set(mousePos.x, mousePos.y);
tooltipText.text.x = tooltipBox.x;
tooltipText.text.y = tooltipBox.y;
tooltipContainer.addChild(tooltipBox);
tooltipContainer.addChild(tooltipText);
//******MEDIA KEYS------------------------------------------------------------------------------------------------------
sfxButton = new PIXI.Graphics(); //Create graphics object
sfxButton.beginFill(0, 0); //Transparent
sfxButton.lineStyle(5, 0x000000); //Black stroke
sfxButton.drawRect(0, 0, 65, 65);
sfxButton.position.set(0, 0);
sfxButton.interactive = true;
sfxButton.buttonMode = true;
sfxButton.alpha = 0.25;
sfxButton.on("mouseover", () => {
sfxButton.alpha = 1;
sfxOnSprite.alpha = 1;
sfxOffSprite.alpha = 1;
if(playSoundEffects) {
updateToolTip("Mute sound effects (S)");
}
else {
updateToolTip("Unmute sound effects (S)");
}
showToolTip();
});
sfxButton.on("mouseout", () => {
sfxButton.alpha = 0.25;
sfxOnSprite.alpha = 0.25;
sfxOffSprite.alpha = 0.25;
hideToolTip();
});
sfxButton.on("pointertap", () => {
muteUnmuteSoundEffects();
if(playSoundEffects) {
sfxOnSprite.visible = true;
sfxOffSprite.visible = false;
}
else {
sfxOnSprite.visible = false;
sfxOffSprite.visible = true;
}
if(playSoundEffects) {
updateToolTip("Mute sound effects (S)");
}
else {
updateToolTip("Unmute sound effects (S)");
}
});
sfxOnSprite.width = sfxOnT.width*.15;
sfxOnSprite.height = sfxOnT.height*.15;
sfxOnSprite.x = sfxButton.x;
sfxOnSprite.y = sfxButton.y;
sfxOnSprite.alpha = 0.25;
sfxOnSprite.visible = true;
sfxOffSprite.width = sfxOffT.width*.15;
sfxOffSprite.height = sfxOffT.height*.15;
sfxOffSprite.x = sfxButton.x;
sfxOffSprite.y = sfxButton.y;
sfxOffSprite.alpha = 0.25;
sfxOffSprite.visible = false;
musicButton = new PIXI.Graphics(); //Create graphics object
musicButton.beginFill(0, 0); //Transparent
musicButton.lineStyle(5, 0x000000); //Black stroke
musicButton.drawRect(0, 0, 65, 65);
musicButton.position.set(sfxButton.x+sfxButton.width+5, 0);
musicButton.interactive = true;
musicButton.buttonMode = true;
musicButton.alpha = 0.25;
musicButton.on("mouseover", () => {
musicButton.alpha = 1;
musicOnSprite.alpha = 1;
musicOffSprite.alpha = 1;
if(!music.paused) {
updateToolTip("Mute music (M)");
}
else {
updateToolTip("Unmute music (M)");
}
showToolTip();
});
musicButton.on("mouseout", () => {
musicButton.alpha = 0.25;
musicOnSprite.alpha = 0.25;
musicOffSprite.alpha = 0.25;
hideToolTip();
});
musicButton.on("pointertap", () => {
playPauseMusic();
if(!music.paused) {
updateToolTip("Mute music (M)");
}
else {
updateToolTip("Unmute music (M)");
}
});
musicOnSprite.width = musicOnT.width*.11;
musicOnSprite.height = musicOnT.height*.11;
musicOnSprite.x = musicButton.x+1;
musicOnSprite.y = musicButton.y+3;
musicOnSprite.alpha = 0.25;
musicOffSprite.width = musicOffT.width*.11;
musicOffSprite.height = musicOffT.height*.11;
musicOffSprite.x = musicButton.x+1;
musicOffSprite.y = musicButton.y+3;
musicOffSprite.alpha = 0.25;
//If the music is playing, show the on sprite and hide the off sprite
if(!music.paused) {
musicOnSprite.visible = true;
musicOffSprite.visible = false;
}
//Else, the music isn't playing so show the off sprite and hdie the on sprite
else {
musicOnSprite.visible = false;
musicOffSprite.visible = true;
}
mediaContainer.addChild(sfxButton);
mediaContainer.addChild(musicButton);
mediaContainer.addChild(sfxOnSprite);
mediaContainer.addChild(sfxOffSprite);
mediaContainer.addChild(musicOnSprite);
mediaContainer.addChild(musicOffSprite);
mediaContainer.position.set(appWidth-mediaContainer.width-(topBarContainer.y+(topBarContainer.height/2)-(mediaContainer.height/2))+5, topBarContainer.y+(topBarContainer.height/2)-(mediaContainer.height/2));
//*******TITLE SCREEN------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
//Create title menu text (ANTS!)
titleMenuTitle = new PIXI.Text("ANTS!", {fontFamily: "Arial", fontSize: 96, fill: 0x000000, align: "center"}); //Create title text
titleMenuTitle.x = (appWidth/2)-(titleMenuTitle.width/2); //x position
titleMenuTitle.y = titleMenuTitle.height; //y position
menuContainer.addChild(titleMenuTitle); //Add to container
//Sign up button------------------------------------------
titleMenuSignUpButton = new PIXI.Graphics(); //Create graphics object
titleMenuSignUpButton.beginFill(0x00FFFF); //Fill blue
titleMenuSignUpButton.lineStyle(5, 0x000000); //Black stroke
titleMenuSignUpButton.drawRect(0, 0, 300, 150); //Draw button
titleMenuSignUpButton.position.set((appWidth/2)-(titleMenuSignUpButton.width/2), appHeight-600); //Set position
titleMenuSignUpButton.interactive = true; //Make it interactive
titleMenuSignUpButton.buttonMode = true; //Make it a button
//When clicked
titleMenuSignUpButton.on("pointertap", () => {
document.getElementById("signuppopup").style.display = "block"; //Show the sign up modal window
});
//Log in button text
titleMenuSignUpButtonText = new PIXI.Text("Sign Up", {fontFamily: "Arial", fontSize: 24, fill: 0x000000, align: "center"}); //Create text
titleMenuSignUpButtonText.position.x = titleMenuSignUpButton.x+(titleMenuSignUpButton.width/2)-(titleMenuSignUpButtonText.width/2); //x position
titleMenuSignUpButtonText.position.y = titleMenuSignUpButton.y+(titleMenuSignUpButton.height/2)-(titleMenuSignUpButtonText.height/2); //y position
menuContainer.addChild(titleMenuSignUpButton); //Add to container
menuContainer.addChild(titleMenuSignUpButtonText); //Add to container
//Create title menu description
titleMenuDescription = new PIXI.Text("You are known far and wide for the wondrous pies that you bake at your windmill. It is rumoured that you might even use advanced forms of science, or even magic, to create such delicacies. Until now, you've been able to bake your pies without much interruption. However, a colony of ants has found the location of your windmill and they will do anything they can to storm your windmill and eat all of your pies! You must defend your windmill from the onslaught of clever ants or your life's work will be ruined!", {fontFamily: "Arial", fontSize: 24, fill: 0x000000, align: "center", wordWrap: "true", wordWrapWidth: "100"}); //Create description text
titleMenuDescription.x = (appWidth/2)-(titleMenuDescription.width/2); //x position
titleMenuDescription.y = (titleMenuTitle.y+titleMenuTitle.height)+((titleMenuSignUpButton.y-(titleMenuTitle.y+titleMenuTitle.height))/2)-(titleMenuDescription.height/2); //y position
menuContainer.addChild(titleMenuDescription); //Add to container
//Guest button------------------------------------------
titleMenuGuestButton = new PIXI.Graphics(); //Create graphics object
titleMenuGuestButton.beginFill(0x00FFFF); //Fill blue
titleMenuGuestButton.lineStyle(5, 0x000000); //Black stroke
titleMenuGuestButton.drawRect(0, 0, 300, 150); //Draw rectangle
titleMenuGuestButton.position.set((appWidth/2)-(titleMenuGuestButton.width/2), titleMenuSignUpButton.y+titleMenuSignUpButton.height+50); //Set position
titleMenuGuestButton.interactive = true; //Make it interactive
titleMenuGuestButton.buttonMode = true; //Make it a button
//When clicked
titleMenuGuestButton.on("pointertap", () => {
player = guestPlayer; //Assign player object as default guestPlayer
loggedIn = true; //Player is "loggedIn"
hideMainMenu(); //Hide the main menu
showLoggedInMenu(); //Show the logged in menu
});
//Guest button text
titleMenuGuestButtonText = new PIXI.Text("Guest", {fontFamily: "Arial", fontSize: 24, fill: 0x000000, align: "center"}); //Create text
titleMenuGuestButtonText.position.x = titleMenuGuestButton.x+(titleMenuGuestButton.width/2)-(titleMenuGuestButtonText.width/2); //x position
titleMenuGuestButtonText.position.y = titleMenuGuestButton.y+(titleMenuGuestButton.height/2)-(titleMenuGuestButtonText.height/2); //y position
menuContainer.addChild(titleMenuGuestButton); //Add to container
menuContainer.addChild(titleMenuGuestButtonText); //Add to container
//Login button------------------------------------------
titleMenuLoginButton = new PIXI.Graphics(); //Create graphics object
titleMenuLoginButton.beginFill(0x00FFFF); //Fill blue
titleMenuLoginButton.lineStyle(5, 0x000000); //Black stroke
titleMenuLoginButton.drawRect(0, 0, 300, 150); //Draw button
titleMenuLoginButton.position.set((appWidth/2)-(titleMenuLoginButton.width/2), titleMenuGuestButton.y+titleMenuGuestButton.height+50); //Set position
titleMenuLoginButton.interactive = true; //Make it interactive
titleMenuLoginButton.buttonMode = true; //Make it a button
//When clicked
titleMenuLoginButton.on("pointertap", () => {
document.getElementById("loginpopup").style.display = "block"; //Show log in modal window
});
//Log in button text
titleMenuLoginButtonText = new PIXI.Text("Log In", {fontFamily: "Arial", fontSize: 24, fill: 0x000000, align: "center"}); //Create text
titleMenuLoginButtonText.position.x = titleMenuLoginButton.x+(titleMenuLoginButton.width/2)-(titleMenuLoginButtonText.width/2); //x position
titleMenuLoginButtonText.position.y = titleMenuLoginButton.y+(titleMenuLoginButton.height/2)-(titleMenuLoginButtonText.height/2); //y position
menuContainer.addChild(titleMenuLoginButton); //Add to container
menuContainer.addChild(titleMenuLoginButtonText); //Add to container
//*******LOGGED IN SCREEN------------------------------------------------------------------------------------------------------------------------------------------------
loggedInMenuTitle = new PIXI.Text("Welcome back, " + player.username + "!", {fontFamily: "Arial", fontSize: 96, fill: 0x000000, align: "center"}); //Create loggedInTitle text
loggedInMenuTitle.x = (appWidth/2)-(loggedInMenuTitle.width/2); //x position
loggedInMenuTitle.y = (loggedInMenuTitle.height); //y position
loggedInMenuTitle.visible = false; //Hide it
menuContainer.addChild(loggedInMenuTitle); //Add to container
//Logged in windmill button------------------------------------------
//Follows same logic as above
loggedInMenuWindmillButton = new PIXI.Graphics();
loggedInMenuWindmillButton.beginFill(0x00FFFF);
loggedInMenuWindmillButton.lineStyle(5, 0x000000);
loggedInMenuWindmillButton.drawRect(0, 0, 300, 150);
loggedInMenuWindmillButton.position.set((appWidth/2)-(loggedInMenuWindmillButton.width/2), loggedInMenuTitle.position.y+loggedInMenuTitle.height+50);
loggedInMenuWindmillButton.interactive = true;
loggedInMenuWindmillButton.buttonMode = true;
loggedInMenuWindmillButton.on("pointertap", () => {
hideLoggedInMenu(); //Hide the logged in menu
showWindmillMenu(); //Show the windmill menu
});
//Windmill button text
loggedInMenuWindmillButtonText = new PIXI.Text("Windmill", {fontFamily: "Arial", fontSize: 24, fill: 0x000000, align: "center"});
loggedInMenuWindmillButtonText.position.x = loggedInMenuWindmillButton.x+(loggedInMenuWindmillButton.width/2)-(loggedInMenuWindmillButtonText.width/2);
loggedInMenuWindmillButtonText.position.y = (loggedInMenuTitle.y+loggedInMenuTitle.height+50+75)-(loggedInMenuWindmillButtonText.height/2);
loggedInMenuWindmillButton.visible = false; //Hide it
loggedInMenuWindmillButtonText.visible = false; //Hide it
//Add to container
menuContainer.addChild(loggedInMenuWindmillButton);
menuContainer.addChild(loggedInMenuWindmillButtonText);
//Logged in towers button------------------------------------------
//Follows same logic as above
loggedInMenuTowersButton = new PIXI.Graphics();
loggedInMenuTowersButton.beginFill(0x00FFFF);
loggedInMenuTowersButton.lineStyle(5, 0x000000);
loggedInMenuTowersButton.drawRect(0, 0, 300, 150);
loggedInMenuTowersButton.position.set((appWidth/2)-(loggedInMenuWindmillButton.width/2), loggedInMenuWindmillButton.y+loggedInMenuWindmillButton.height+50);
loggedInMenuTowersButton.interactive = true;
loggedInMenuTowersButton.buttonMode = true;
loggedInMenuTowersButton.on("pointertap", () => {
hideLoggedInMenu(); //Hide the logged in menu
showTowersMenu(); //Show the towers menu
});
//Towers button text
loggedInMenuTowersButtonText = new PIXI.Text("Towers", {fontFamily: "Arial", fontSize: 24, fill: 0x000000, align: "center"});
loggedInMenuTowersButtonText.position.x = loggedInMenuTowersButton.x+(loggedInMenuTowersButton.width/2)-(loggedInMenuTowersButtonText.width/2);
loggedInMenuTowersButtonText.position.y = loggedInMenuTowersButton.y+(loggedInMenuTowersButton.height/2)-(loggedInMenuTowersButtonText.height/2);
loggedInMenuTowersButton.visible = false; //Hide it
loggedInMenuTowersButtonText.visible = false; //Hide it
//Add to container
menuContainer.addChild(loggedInMenuTowersButton);
menuContainer.addChild(loggedInMenuTowersButtonText);
//Logged in play button------------------------------------------
//Follows same logic as above
loggedInMenuPlayButton = new PIXI.Graphics();
loggedInMenuPlayButton.beginFill(0x00FFFF);
loggedInMenuPlayButton.lineStyle(5, 0x000000);
loggedInMenuPlayButton.drawRect(0, 0, 300, 150);
loggedInMenuPlayButton.position.set((appWidth/2)-(loggedInMenuPlayButton.width/2), loggedInMenuTowersButton.y+loggedInMenuTowersButton.height+50);
loggedInMenuPlayButton.interactive = true;
loggedInMenuPlayButton.buttonMode = true;
loggedInMenuPlayButton.on("pointertap", () => {
hideLoggedInMenu(); //Hide the logged in menu
showLevelMenu(); //Show the level menu
});
//Play button text
loggedInMenuPlayButtonText = new PIXI.Text("Play", {fontFamily: "Arial", fontSize: 24, fill: 0x000000, align: "center"});
loggedInMenuPlayButtonText.position.x = loggedInMenuPlayButton.x+(loggedInMenuPlayButton.width/2)-(loggedInMenuPlayButtonText.width/2);
loggedInMenuPlayButtonText.position.y = loggedInMenuPlayButton.y+(loggedInMenuPlayButton.height/2)-(loggedInMenuPlayButtonText.height/2);
loggedInMenuPlayButton.visible = false; //Hide it
loggedInMenuPlayButtonText.visible = false; //Hide it
//Add to container
menuContainer.addChild(loggedInMenuPlayButton);
menuContainer.addChild(loggedInMenuPlayButtonText);
//Logged in log out button------------------------------------------
//Follows same logic as above
loggedInMenuLogOutButton = new PIXI.Graphics();
loggedInMenuLogOutButton.beginFill(0x00FFFF);
loggedInMenuLogOutButton.lineStyle(5, 0x000000);
loggedInMenuLogOutButton.drawRect(0, 0, 300, 150);
loggedInMenuLogOutButton.position.set((appWidth/2)-(loggedInMenuLogOutButton.width/2), loggedInMenuPlayButton.y+loggedInMenuPlayButton.height+50);
loggedInMenuLogOutButton.interactive = true;
loggedInMenuLogOutButton.buttonMode = true;
loggedInMenuLogOutButton.on("pointertap", () => {
hideLoggedInMenu(); //Hide the logged in menu
logOut(); //Log the player out
showMainMenu(); //Show the main menu
});
//LogOut button text
loggedInMenuLogOutButtonText = new PIXI.Text("Log Out", {fontFamily: "Arial", fontSize: 24, fill: 0x000000, align: "center"});
loggedInMenuLogOutButtonText.position.x = loggedInMenuLogOutButton.x+(loggedInMenuLogOutButton.width/2)-(loggedInMenuLogOutButtonText.width/2);