-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut_main.php
2870 lines (2447 loc) · 281 KB
/
tut_main.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
<!DOCTYPE html>
<!-- This is a declaration to tell the browser which version of HTML the page is using -->
<html lang="en">
<!-- This is the start of my code-->
<!-- This is the head of the code. In here I can change the title and link other files to my page-->
<head>
<!--This is the text that will appear on the tab in the browser-->
<title>Process. IT.</title>
<!--CONNECTING MY HTML FILE WITH OTHER CSS FILES-->
<!--I'm resetting the browser styles-->
<link href="css/reset.css" rel="stylesheet">
<!--I'm importing nicer type-->
<link href="css/text.css" rel="stylesheet">
<!--linking 960 stylesheet-->
<link href="css/960.css" rel="stylesheet">
<!-- linking the stylesheet -->
<link href="css/tut_main.css" rel="stylesheet">
<!--CONNECTING GOOGLE FONTS-->
<!--Im connecting Google fonts here with the weight of the font as 400 light and 900 for bold-->
<link href='https://fonts.googleapis.com/css?family=Merriweather:400,900' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Oswald:400,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Lato:400,900' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Yeseva+One' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,900,300,300italic' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Aldrich' rel='stylesheet' type='text/css'>
</head>
<!--This is the end of the head-->
<!--This is the body where all of the content is-->
<body>
<!--The PHO for comments section which-->
<?php
if ($_POST)
{
$servername = "daneel";
$username = "N00152627";
$password = "N00152627";
$dbname = "n00152627playground";
$users_name = $_POST['username'];
$users_comment = $_POST['comment'];
$users_name = str_replace("'", "''", "$users_name");
$users_comment = str_replace("'", "''", "$users_comment");
// Create connection to the DB
$conn = new mysqli($servername, $username, $password,$dbname);
// Check connection was created successfully
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
// SQL to create a table
$sql = "INSERT INTO comments (username, comment) VALUES ('$users_name','$users_comment');";
//Check that the SQL command ran correctly
if ($conn->multi_query($sql) === TRUE) {
}
else
{
echo "Error inputting data: " . $conn->error;
}
//Close the connection to the DB
$conn->close();
}
?>
<!-- The div is like a container which I will style using CSS -->
<!--The class is a name assigned to this container in which I will be able to style-->
<div class="wrapper_main">
<!--The container using the 12 collumn grid which is connected to the 960 stylesheet-->
<div class="container_12 main">
<div class="triangle">
<p id="game">GAME</p>
<img class="hand" src="images/hand.png" alt="hand" />
<div class="navigation">
<!--This is the navigation class where all the links go-->
<!--Unordered List element which is used to create the navigational links-->
<ul>
<!-- a href will link to other html documents creating a navigation system-->
<li id="home"><a id="nav" href="index.html">Home</a></li>
<li id="tutorials"><a id="nav" href="tutorials.html">Tutorials</a></li>
<li id="about"><a id="nav" href="about.html">About</a></li>
<li id="users"><a id="nav" href="users.html">Users</a></li>
<!--This is the end of the lists-->
</ul>
<!--This is the end of the navigation div-->
</div>
</div>
<!--Im creating another div in order to be able to move around the attributes together-->
<div class="logo grid_3">
<!--This is a JavaScript document which Im stating here and which connects to the document outlined in "src"-->
<script src="js/date.js "></script>
<!--This will be my h1 text-->
<h1> Process. </h1>
<!--This will be my h2 text-->
<h2>IT.</h2>
<!--This is the end of the logo div-->
</div>
<!--This is a div which is used for decoration to create a triangle for the logo-->
<div class="small_rectangle"></div>
<div class="grid_9">
<p id="title">Combination Game</p>
<p id="published">Published by: Erika Volodko</p>
<p id="date">15 / 03 / 2016</p>
<hr />
</div>
<!--This is the slideshow container-->
<div class="grid_12">
<div id="contentContainer">
<div id="wrapper">
<div id="itemOne" class="content">
<!--The first window of the slideshow-->
<p id="slide_start">Please wait till the slideshow fully loads
<br />and then use circle steps <ins>in order</ins>
<br /> from left to right to start.</p>
<!--This is the animation of a runner in a circle-->
<div class="circle">
<div class="runner"> </div>
</div>
</div>
<!--Second Slideshow-->
<div id="itemTwo" class="content">
<div class="step_1"><font id="step_1_title">Step 1</font>
<br />Open up <i><acronym title="If you don't have this application you can look at the resources section to get the link">processing application</acronym></i>.
<br /> Go to <b>file</b> at the top left corner
<br /> and select <ins>save as</ins>.
<br />
<br />Save on your desktop as "<font id="game_text">game</font>".
<br />This will create a folder on your
<br /> desktop by that file name.</div>
<img src="images/step_1.png" id="img1" />
</div>
<!--Third Slideshow-->
<div id="itemThree" class="content">
<div class="step_1"><font id="step_2_title">Step 2</font>
<br />Open up the folder in desktop
<br /> and <ins>right click</ins>.
<br /> Select "<b>New</b>" and then "<b>Folder</b>".
<br />
<br />This will be our <font id="images_fonts">images and fonts</font>.
<br />Once you've done that, open up
<br /> the game file that's there.
<br />
<br /><font id="note">Note:</font> <i>Download the files below<br /> to put into the data folder.</i></div>
<img src="images/step_2.png" id="img2" />
</div>
<!--Fourth Slideshow-->
<div id="itemFour" class="content">
<div class="step_1"><font id="step_3_title">Step 3</font>
<br />Once you did the previous steps,
<br /> you need to create your <b>game<br /> skeleton</b>. We can do that
<br /> by creating <acronym title="A data element which is referenced with a name. Every variable has a value, data type and scope.">variables</acronym>.
<br />
<br />Create the <acronym title="This will give us the opportunity to have multiple screens like in a normal game">scene change</acronym> variable.
<br />Let's call it "<b id="currentScreen">currentScreen</b>".
<br />
<br />
</b>Now we need to create a <acronym title="A loop is a piece of block code which will run constantly until stopped.">loop</acronym>.</div>
<img src="images/step_3.png" id="img3" />
</div>
<!--Fifth Slideshow-->
<div id="itemFive" class="content">
<div class="step_1"><font id="step_4_title">Step 4</font>
<br />Create a <acronym id="acronym2" title="This code block runs in a loop until stopped or the application is exited. It can only be used once.">draw()</acronym> loop for the scenes to
<br /> change when we have a <acronym id="acronym2" title="A command in this sense is when user clicks on the mouse or presses the keyboard"> command</acronym>.
<br />
<br /> Add a <acronym id="acronym2" title="This will enable the currentScreen variable to switch when a command is made">switch</acronym> to the currentScreen
<br /> variable. In the <b>switch()</b> structure,
<br /> <acronym id="acronym2" title="Case is a label for different switch statements">Cases </acronym>and <acronym id="acronym2" title="We let the program know that we are finished with a specific case label by using 'break' at the end ">breaks</acronym> will let you
<br />label scenes.
<br />
<br /> Create a scene <acronym id="acronym2" title="A name will be used to recall this code later on">title</acronym> in each case.
<br /><font id="note"></div>
<img src="images/step_4.png" id="img4" />
</div>
<!--Sixth Slideshow-->
<div id="itemSix" class="content">
<div class="step_1"><font id="step_5_title">Step 5</font>
<br />In order to <b>re-call</b> cases and draw
<br />loop later on in the code, use <acronym title="Keyword used indicate that a function returns no value.">void</acronym>
<br /> and the case <b>title</b> followed after
<br /> with a loop.
<br />
<br />Now we need to add the <acronym title="Setup() will only run once once the program starts. Its used to define screen size and load fonts, images and etc.">setup()</acronym> loop
<br />to initialize the canvas and finish
<br />the game skeleton.</b>
</div>
<img src="images/step_5.png" id="img5" />
</div>
<!--Seventh Slideshow-->
<div id="itemSeven" class="content">
<div class="step_1"><font id="step_6_title">Step 6</font>
<br />Last step to finishing the skeleton
<br /> of the game is to add the main
<br /> <b>image</b> and <b>font</b> variables.
<br />
<br />We also need to <acronym id="acronym2" title="Defining the canvas size will create a window in which our images will be. The canvas is set the exact same size as the background image.">define</acronym> our
<br />canvas settings in setup().
<br />
<br /><b>Copy</b> the code as outlined, then
<br/> <acronym id="acronym2" title="Using this command the program will load images and other files from our 'data' folder">load</acronym> image variables and fonts
<br /> in the setup loop. </div>
<img src="images/step_6.png" id="img6" />
</div>
<!--Eight Slideshow-->
<div id="itemEight" class="content">
<div class="step_1"><font id="step_7_title">Step 7</font>
<br />Now that the main structure is done,
<br /> we can start adding <acronym title="All the variables we declared previously">content</acronym> to
<br /> our <b>scenes</b> made previously.
<br />
<br /> All we need to do is, tell
<br />the application to <b>recall</b>
<br /> the variables that we used
<br /> in setup().
<br />
<br />This is our "<b id="start_screen">Start</b>" screen. </div>
<img src="images/step_7.png" id="img7" />
</div>
<!--Nineth Slideshow-->
<div id="itemNine" class="content">
<div class="step_1"><font id="step_8_title">Step 8</font>
<br />Click the <acronym id="acronym2" title="Run is the circular button on the top left corner of the application with an arrow in it">Run</acronym> button to see how
<br />the <b>start</b> looks so far.
<br />We need to create <b>interactivity</b>,
<br /> between the scenes.
<br />To do so, use <acronym id="acronym2" title="This function is used to run the block code when a user presses a key. This key is stored in the 'key' function ">keyPressed()</acronym>.
<br />We will use an <acronym id="acronym2" title="Gives the program a command to execute a loop block code if a certain condition is true">if</acronym> loop to determine
<br /> which <b>key</b> needs to be pressed
<br /> in order for the currentScreen
<br />variable to <b>change and switch</b>
<br /> to a different case.</div>
<img src="images/step_8.png" id="img8" />
</div>
<!--Tenth Slideshow-->
<div id="itemTen" class="content">
<div class="step_1"><font id="step_9_title" "#step_9_jump_back">Step 9</font>
<br />Now we need to create <b>instructions</b>
<br /> of the game in the next screen.
<br />
<br /> By using fonts and the image
<br /> <b>variables</b> declared previously,
<br /> all we need to do is position
<br />them the way we want and.
<br />
<br /> <a id="step_9_click" href="#step_9_jump">Click here to get the full code.</a></div>
<img src="images/step_9.png" id="img9" />
</div>
<!--Eleventh Slideshow-->
<div id="itemEleven" class="content">
<div class="step_1"><font id="step_10_title">Step 10</font>
<br />For the <b>main game</b>, some sort of
<br />animation is needed. Which is why
<br /> using an <acronym id="acronym2" title="This is a list of data which is identified by an index number. It starts from 0 and and then counts up.">array</acronym> is a good choice.
<br />
<br />Create new variables above your
<br /> main code, and then declare
<br /> <acronym id="acronym2" title="Datatype to store images, it needs to be loaded before initialized">PImage </acronym>array like on the left.
<br />Create a <acronym id="acronym2" title="This will speed up or slow down the animation">frameRate</acronym> for your
<br /> animation, and then a <acronym id="acronym2" title="This controls the sequence of repetitions so that the animation runs smoothly">for</acronym> loop
<br /> to have it running.</div>
<img src="images/step_10.png" id="img10" />
</div>
<!--Twelveth Slideshow-->
<div id="itemTwelve" class="content">
<div class="step_1"><font id="step_11_title">Step 11</font>
<br /> Most of the <b>structure</b> variables are
<br /> set up, now we need to <b>add</b> the
<br />arrays we declared to our scenes.
<br /> Copy the code on the left or
<br />
<br /><a id="step_11_click" href="#step_11_jump">Click here to get the code.</a>
<br />
<br />We will use the <b>image function once</b>
<br /> again to recall our array <b>png files</b>
<br /> and position them. </div>
<img src="images/step_11.png" id="img11" />
</div>
<!--Thirteenth Slideshow-->
<div id="itemThirteen" class="content">
<div class="step_1"><font id="step_12_title">Step 12</font>
<br />It's time to create our <b>potions</b>.
<br />In the game the user will need
<br />to click <b>two ingredients</b> to create
<br />the actual potions.
<br />When they choose their ingredient,
<br /> it will <b>disappear.</b> To do that we
<br /> will use a <acronym id="acronym2" title="This is a true or false data type, so when a certain condition is met and the boolean is either set to true or false, the outcome will depend. In this case when potions are set to false, they will disappear.">boolean</acronym> data type.
<br />
<br />Declare the variables like on the
<br />left and <b>load</b> them in setup().</div>
<img src="images/step_12.png" id="img12" />
</div>
<!--Fourteenth Slideshow-->
<div id="itemFourteen" class="content">
<div class="step_1"><font id="step_13_title">Step 13</font>
<br />Go back to <b>currentScreenTwo()</b>
<br /> code and add in the <b>if</b> loop
<br />statements for each
<br />of the ingridients and their position
<br /> on the <b>x and y</b> axis.
<br />
<br />Run the code to see if it works.
<br />
<br /><a id="step_13_click" href="#step_13_jump">Click here to get the code so far.</a></div>
<img src="images/step_13.png" id="img13" />
</div>
<!--Fifteenth Slideshow-->
<div id="itemFifteen" class="content">
<div class="step_1"><font id="step_14_title">Step 14</font>
<br />Now we need to create our
<br /> <b id="combinations_b">Combinations</b> for the ingredients.
<br /> Go back to the code start.
<br />Add the combination variables and
<br />add <b>images</b> for the different
<br />outcomes. We will use all the
<br />images that are in the <b>data folder</b>.
<br /> You may have noticed we're using
<br /> <acronym title="Int is a numerical data type which can only store numbers">int</acronym> data type for <ins>numeral values</ins>. This
<br /> is the best data type to use.
<br />
</div>
<img src="images/step_14.png" id="img14" />
</div>
<!--Sixteenth Slideshow-->
<div id="itemSixteen" class="content">
<div class="step_1"><font id="step_15_title">Step 15</font>
<br />Once you have your <b>combinations</b>
<br />ready, and declared the image
<br /> variables, recall the variables
<br /> in setup().
<br />
<br /><a id="step_15_click" href="#step_15_jump">Click here to get the code so far.</a>
<br />
<br />We can now start creating the
<br />screen changes and game itself.</div>
<img src="images/step_15.png" id="img15" />
</div>
<!--Seventeenth Slideshow-->
<div id="itemSeventeen" class="content">
<div class="step_1"><font id="step_16_title">Step 16</font>
<br />Let's finish the design
<br />of our scences.
<br />
<br/>Go back to <b>drawScreenThree()</b>
<br />and repeat the same process as
<br />for <b>drawScreenTwo()</b>.
<br />
<br /> Add arrays, images and fonts.</div>
<img src="images/step_16.png" id="img16" />
</div>
<!--Eighteenth Slideshow-->
<div id="itemEighteen" class="content">
<div class="step_1"><font id="step_17_title">Step 17</font>
<br />The last part to this section
<br />is to add in content to
<br /> <b>drawScreenFour() </b>scene.
<br />
<br />Once again, add in arrays,
<br />images and fonts.</div>
<img src="images/step_17.png" id="img17" />
</div>
<!--Nineteenth Slideshow-->
<div id="itemNineteen" class="content">
<div class="step_1"><font id="step_18_title">Step 18</font>
<br />This section will cover the combination
<br />variables that we declared.
<br />
<br />Go to <b id="currentScreenThree">currentScreenThree()</b> scene
<br />and create <b>if</b> statements with the
<br />combinations on the left.
<br />
<br />Then after each statement, recall
<br />our result potions (<b>endpotion</b>) and
<br />position them on <b>x and y</b> axis.</div>
<img src="images/step_18.png" id="img18" />
</div>
<!-- Slideshow Twenty-->
<div id="itemTwenty" class="content">
<div class="step_1"><font id="step_19_title">Step 19</font>
<br />Now we need to create bad potion
<br /> combination results.
<br />
<br />These are the creatures that the
<br />character will turn into if the
<br /> ingredient combination was wrong.
<br />Go to <b id="currentScreenFour">currentScreenFour()</b>
<br /> scene and add the following
<br />code on the left.</div>
<img src="images/step_19.png" id="img19" />
</div>
<!-- Slideshow Twenty One-->
<div id="itemTwentyOne" class="content">
<div class="step_1"><font id="step_20_title">Step 20</font>
<br />We will use combinations for
<br /><acronym id="acronym2" title="Interactivity can be when the user presses a key like in keyPressed function mentioned earlier or in this case the 'mousePressed' option">interactivity</acronym> using <acronym id="acronym2" title="This will let the program know that when a user clicks something , in this case the co-ordinates outlined, a scene will change">mousePressed()</acronym>
<br /> function.
<br />
<br />When our <b>currentScreen</b> is equal
<br /> to 2, and the user clicks along the
<br /><b>x and y</b> co-ordinates like on the left,
<br />the combination variable will <b><acronym id="acronym2" title="When it will store the value and the user will click witihin the co-ordinates declared in the if statement, the scene will change.">store</acronym></b>
<br />the new value.</div>
<img src="images/step_20.png" id="img20" />
</div>
<!-- Slideshow Twenty Two-->
<div id="itemTwentyTwo" class="content">
<div class="step_1"><font id="step_21_title">Step 21</font>
<br />Now we need to add the second
<br /> row of ingredients to our
<br />combination <b>mousePressed()</b>
<br />function.
<br />
<br /> Use the same method as in
<br /> the previous step. </div>
<img src="images/step_21.png" id="img21" />
</div>
<!-- Slideshow Twenty Three-->
<div id="itemTwentyThree" class="content">
<div class="step_1"><font id="step_22_title">Step 22</font>
<br />Using the combination variable
<br /> results from the user , depending
<br /> on where they click, and creating
<br /><b>scene changes</b>.
<br />The code on the left shows
<br /> the layout of the loop.
<br /> The combination values are shown
<br />in red. This code needs to be
<br />inside the <b> mousePressed()</b> loop.</div>
<img src="images/step_22.png" id="img22" />
</div>
<!-- Slideshow Twenty Four-->
<div id="itemTwentyFour" class="content">
<div class="step_1"><font id="step_23_title">Step 23</font>
<br />Last step in this section is
<br /> to allow the proper scene
<br /> change when user clicks on the
<br /><b>finished potion</b>. We will use
<br />another <b>if</b> loop like the
<br />code on the left.
<br />
<br /><a id="step_23_click" href="#step_23_jump">Click here to get the full code.</a></div>
<img src="images/step_23.png" id="img23" />
</div>
<!-- Slideshow Twenty Five-->
<div id="itemTwentyFive" class="content">
<div class="step_1"><font id="step_24_title">Step 24</font>
<br />Declare a "<b id="lives">lives</b>" variable at
<br />the start of the code. Then recall
<br /> it in <b>drawScreenTwo()</b>.
<br/>
<br />When lives will be equal to zero,
<br />the game will end.
<br />
<br />We are setting the lives to <b>Four</b>
<br />so that the user has a chance
<br />to guess the right potion.</div>
<img src="images/step_24.png" id="img24" />
</div>
<!-- Slideshow Twenty Six-->
<div id="itemTwentySix" class="content">
<div class="step_1"><font id="step_25_title">Step 25</font>
<br />Add the newly created <b>lives</b> variable
<br /> to end of <b>drawScreenThree()</b>
<br />code and <b>drawScreenFour</b> like
<br />outlined on the left.
<br />
<br /><a id="step_25_click" href="#step_25_jump">Click here to get the code.</a>
<br /> </div>
<img src="images/step_25.png" id="img25" />
</div>
<!-- Slideshow Twenty Seven-->
<div id="itemTwentySeven" class="content">
<div class="step_1"><font id="step_26_title">Step 26</font>
<br />The last part to this section is
<br />to add in <b id="lives_b">lives--;</b> code in the
<br />combinations we have at the
<br />end of the code.
<br />
<br />This will enable a lives <b>system</b>,
<br />where the user will lose
<br /> a life once the combination
<br />of the ingredients they chose
<br />was wrong. </div>
<img src="images/step_26.png" id="img26" />
</div>
<!-- Slideshow Twenty Eight-->
<div id="itemTwentyEight" class="content">
<div class="step_1"><font id="step_27_title">Step 27</font>
<br />In this section we will be adding
<br /> the different potion results that
<br />are <b>successful</b>. There are only <b>three</b>.
<br />
<br />Copy the code in the link below or
<br />create your own text.
<br />
<br /> <a id="step_27_click" href="#step_27_jump">Click here to get the code.</a></div>
<img src="images/step_27.png" id="img27" />
</div>
<!-- Slideshow Twenty nine-->
<div id="itemTwentyNine" class="content">
<div class="step_1"><font id="step_28_title">Step 28</font>
<br />Add a similar code to the
<br /> second <b>end()</b> result.
<br />
<br />This is will replace the first image.
<br />
<br />Copy the code in the link below or
<br />create your own text.
<br />
<br /> <a id="step_28_click" href="#step_28_jump">Click here to get the code.</a></div>
<img src="images/step_28.png" id="img28" />
</div>
<!-- Slideshow Thirty-->
<div id="itemThirty" class="content">
<div class="step_1"><font id="step_29_title">Step 29</font>
<br />Add the last end result code
<br /> with the similar code as before.
<br />
<br />This is will replace the second image.
<br />
<br />Copy the code in the link below or
<br />create your own text.
<br />
<br /> <a id="step_29_click" href="#step_29_jump">Click here to get the code.</a></div>
<img src="images/step_29.png" id="img28" />
</div>
<!-- Slideshow Thirty One-->
<div id="itemThirtyOne" class="content">
<div class="step_1"><font id="step_30_title">Step 30</font>
<br />In order to have sound, we need
<br /> to <acronym id="acronym2" title="we will import data from other sites or tools in processing in order to have more features, in this case sound.">import</acronym> a music library.
<br />
<br />Go to "<b>Tools</b>" and then "<b>Add Tools...</b>"
<br />Type in <b>minim</b> and select
<br />and download the library.
<br />
</div>
<img src="images/step_30.png" id="img30" />
</div>
<!-- Slideshow Thirty Two-->-->
<div id="itemThirtyTwo" class="content">
<div class="step_1"><font id="step_31_title">Step 31</font>
<br />Now all you need to do is
<br />to declare the <b>input</b> before
<br />all of your code and recall it,
<br />in setup().
<br />
<br />
</b>You can now use
<br />the code in any part
<br /> of the game
<br />
</div>
<img src="images/step_31.png" id="img31" />
</div>
<!-- Slideshow Thirty Three-->
<div id="itemThirtyThree" class="content">
<div class="step_1"><font id="step_32_title">Step 32</font>
<br />You need to <acronym id="acronym2" title="This will let the program move more smoothly and allow some features to work better">reset</acronym> some variables
<br /> in order for the others
<br />to move smooth.
<br />
<br /> We declared a reset variable back
<br /> when we declared <b>keyPressed()</b>.
<br /> All you need to do now is go into
<br />the <b>reset()</b> code block you made
<br />at the end and type in the
<br />code on the left. </div>
<img src="images/step_32.png" id="img32" />
</div>
<!-- Slideshow Thirty Four LAST SLIDESHOW-->
<div id="itemThirtyFour" class="content">
<div class="step_1"><font id="step_33_title">Step 33</font>
<br /><b>Final Step</b> is to create the ending
<br />screen. It's almost the same
<br /> as the starting screen
<br />however you need to change
<br />the text.
<br />
<br /> This is all for
<br /> this tutorial, make sure to
<br /> check the code below!</div>
<img src="images/step_33.png" id="img33" />
</div>
</div>
</div>
<!--This is the bulletpoints of the slideshow, data position is 770px added constantly for each slide fram-->
<div id="navLinks">
<ul>
<p id="slide_1">Structure</p>
<li class="itemLinks" data-pos="0px"></li>
<li class="itemLinks" data-pos="-770px"></li>
<li class="itemLinks" data-pos="-1540px"></li>
<li class="itemLinks" data-pos="-2310px"></li>
<li class="itemLinks" data-pos="-3080px"></li>
<li class="itemLinks" data-pos="-3850px"></li>
<li class="itemLinks" data-pos="-4620px"></li>
<li class="itemLinks" data-pos="-5390px"></li>
<li class="itemLinks" data-pos="-6160px"></li>
<li class="itemLinks" data-pos="-6930px"></li>
<li class="itemLinks" data-pos="-7700px"></li>
</ul>
<ul>
<p id="slide_2">Game</p>
<li class="itemLinks" data-pos="-8470px"></li>
<li class="itemLinks" data-pos="-9240px"></li>
<li class="itemLinks" data-pos="-10010px"></li>
<li class="itemLinks" data-pos="-10780px"></li>
<li class="itemLinks" data-pos="-11550px"></li>
<li class="itemLinks" data-pos="-12320px"></li>
<li class="itemLinks" data-pos="-13090px"></li>
</ul>
<ul>
<p id="slide_3">Combine</p>
<li class="itemLinks" data-pos="-13860px"></li>
<li class="itemLinks" data-pos="-14630px"></li>
<li class="itemLinks" data-pos="-15400px"></li>
<li class="itemLinks" data-pos="-16170px"></li>
<li class="itemLinks" data-pos="-16940px"></li>
<li class="itemLinks" data-pos="-17710px"></li>
</ul>
<ul>
<p id="slide_4">Lives</p>
<li class="itemLinks" data-pos="-18480px"></li>
<li class="itemLinks" data-pos="-19250px"></li>
<li class="itemLinks" data-pos="-20020px"></li>
</ul>
<ul>
<p id="slide_5">End</p>
<li class="itemLinks" data-pos="-20790px"></li>
<li class="itemLinks" data-pos="-21560px"></li>
<li class="itemLinks" data-pos="-22330px"></li>
</ul>
<ul>
<p id="slide_6">Sound</p>
<li class="itemLinks" data-pos="-23100px"></li>
<li class="itemLinks" data-pos="-23870px"></li>
</ul>
<ul>
<p id="slide_7">Finish</p>
<li class="itemLinks" data-pos="-24640px"></li>
<li class="itemLinks" data-pos="-25410px"></li>
</ul>
</div>
<script src="//www.kirupa.com/html5/examples/js/prefixfree.min.js"></script>/
<!--In case the browser does not support the slideshow-->
<!--This is the script for the changing of slides-->
<script src="js/structure.js "></script>
</div>
<hr id="hr2">
<!--THIS CODE WAS COPIED AS HTML IN PROCESSING AND THEN PLACED INTO MY OWN CODE HERE-->
<p id="code_title">CODE</p>
<div class="code grid_10">
<p id="code_text">Simplified Game Skeleton</p><pre>
<span style="color: #666666;">//Screen change variable declared</span>
<span style="color: #E2661A;">int</span> currentScreen; <span style="color: #666666;">//Variable to create the different scenes(screens) for interaction</span>
<span style="color: #666666;">//Font Variables declared</span>
<span style="color: #E2661A;">PFont</span> font, font2; <span style="color: #666666;">//Declare PFont variable</span>
<span style="color: #666666;">// setup() function only runs once</span>
<span style="color: #33997E;">void</span> <span style="color: #006699;"><b>setup</b></span>() { <span style="color: #666666;">//Start of setup loop </span>
}
<span style="color: #666666;">//end of loop</span>
<span style="color: #666666;">// draw() loops forever, until stopped</span>
<span style="color: #33997E;">void</span> <span style="color: #006699;"><b>draw</b></span>() { <span style="color: #666666;">//Start of draw loop</span>
<span style="color: #669900;">switch</span>(currentScreen) { <span style="color: #666666;">//Controls the jumps to different screens in this case the integer which is currentScreen</span>
<span style="color: #33997E;">case</span> 0: <span style="color: #666666;">//Cases are the value of currentScreen</span>
drawScreenZero(); <span style="color: #666666;">//Name of the first currentScreen</span>
<span style="color: #33997E;">break</span>; <span style="color: #666666;">//Ends the execution of this part in switch()</span>
<span style="color: #33997E;">case</span> 1: <span style="color: #666666;">//currentScreen is now 1 </span>
drawScreenOne(); <span style="color: #666666;">//Name of the second currentScreen</span>
<span style="color: #33997E;">break</span>; <span style="color: #666666;">//Ends the execution of this part in switch()</span>
<span style="color: #33997E;">case</span> 2: <span style="color: #666666;">//currentScreen is now 2</span>
drawScreenTwo(); <span style="color: #666666;">//Name of the third currentScreen</span>
<span style="color: #33997E;">break</span>; <span style="color: #666666;">//Ends the execution of this part in switch() </span>
<span style="color: #33997E;">case</span> 3: <span style="color: #666666;">//currentScreen is now 3</span>
drawScreenThree(); <span style="color: #666666;">//Name of the fourth currentScreen</span>
<span style="color: #33997E;">break</span>; <span style="color: #666666;">//Ends the execution of this part in switch()</span>
<span style="color: #33997E;">case</span> 4: <span style="color: #666666;">//currentScreen is now 4</span>
drawScreenFour(); <span style="color: #666666;">//Name of the fifth currentScreen</span>
<span style="color: #33997E;">break</span>; <span style="color: #666666;">//Ends the execution of this part in switch()</span>
<span style="color: #33997E;">case</span> 5: <span style="color: #666666;">//currentScreen is now 5</span>
end1(); <span style="color: #666666;">//Name for the end result</span>
<span style="color: #33997E;">break</span>; <span style="color: #666666;">//Ends the execution of this part in switch()</span>
<span style="color: #33997E;">case</span> 6: <span style="color: #666666;">//currentScreen is now 6</span>
end2(); <span style="color: #666666;">//Name for the second end result</span>
<span style="color: #33997E;">break</span>; <span style="color: #666666;">//Ends the execution of this part in switch()</span>
<span style="color: #33997E;">case</span> 7: <span style="color: #666666;">//currentScreen is now 7</span>
end3(); <span style="color: #666666;">//Name for the third end result</span>
<span style="color: #33997E;">break</span>; <span style="color: #666666;">//Ends the execution of this part in switch()</span>
<span style="color: #33997E;">case</span> 8: <span style="color: #666666;">//If the currentScreen is now 8 that means its the end of the game</span>
endOfGame(); <span style="color: #666666;">//Name of the last screen</span>
<span style="color: #33997E;">break</span>; <span style="color: #666666;">//Ends the execution of this part in switch()</span>
}
}
<span style="color: #666666;">//end of loop</span>
<span style="color: #666666;">//Drawing the currentScreen 0 </span>
<span style="color: #33997E;">void</span> drawScreenZero() {
}
<span style="color: #666666;">//end of loop</span>
<span style="color: #666666;">//Drawing the currentScreen 1</span>
<span style="color: #33997E;">void</span> drawScreenOne() {
}
<span style="color: #666666;">//end of loop</span>
<span style="color: #666666;">//Drawing the currentScreen 2</span>
<span style="color: #33997E;">void</span> drawScreenTwo() {
}
<span style="color: #666666;">//end of loop</span>
<span style="color: #666666;">//Drawing the currentScreen 3</span>
}
<span style="color: #666666;">//end of loop</span>
<span style="color: #666666;">//Drawing the currentScreen 4</span>
<span style="color: #33997E;">void</span> drawScreenFour() {
}
<span style="color: #666666;">//end of loop</span>
<span style="color: #666666;">//Drawing the result screen 5</span>
<span style="color: #33997E;">void</span> end1 () {
}
<span style="color: #666666;">//end of loop{//Drawing the result screen 6</span>
<span style="color: #33997E;">void</span> end2 () {
}
<span style="color: #666666;">//end of loop</span>
<span style="color: #666666;">//Drawing the result screen 7</span>
<span style="color: #33997E;">void</span> end3 () {
}
<span style="color: #666666;">//end of loop{//The reset variable which is recalled in the if keyPressed statement </span>
<span style="color: #33997E;">void</span> reset() {
}
<span style="color: #666666;">//end of loop</span>
<span style="color: #666666;">//END OF GAME</span>
<span style="color: #33997E;">void</span> endOfGame(){
}
<span style="color: #666666;">//end of loop</span>
</pre></div>
<div class="code2 grid_10">
<p id="code2_text">All Variables</p><pre>
<span style="color: #666666;">//Audio</span>
Minim minim; <span style="color: #666666;">//Sound player variable</span>
AudioPlayer song, water, bubbling, wand, slurp; <span style="color: #666666;">//Audio song variable names</span>
<span style="color: #E2661A;">boolean</span> playing= <span style="color: #33997E;">false</span>; <span style="color: #666666;">//Boolean to show the song is playing</span>
<span style="color: #E2661A;">String</span> soundeffect = <span style="color: #7D4793;">"bubbling.mp3"</span>; <span style="color: #666666;">//Loading a music file </span>
<span style="color: #E2661A;">String</span> soundeffect2 = <span style="color: #7D4793;">"wand.mp3"</span>; <span style="color: #666666;">//Loading a music file </span>
<span style="color: #E2661A;">String</span> soundeffect3 = <span style="color: #7D4793;">"slurp.mp3"</span>; <span style="color: #666666;">//Loading a music file </span>
AudioPlayer[] player = <span style="color: #33997E;">new</span> AudioPlayer[1]; <span style="color: #666666;">//Creating a player array so the song plays in a loop</span>
AudioPlayer[] player2 = <span style="color: #33997E;">new</span> AudioPlayer[1]; <span style="color: #666666;">//Creating a player array so the song plays in a loop</span>
<span style="color: #666666;">//Screen change variable declared</span>
<span style="color: #E2661A;">int</span> currentScreen; <span style="color: #666666;">//Variable to create the different scenes(screens) for interaction</span>
<span style="color: #666666;">//Image variables declared</span>
<span style="color: #E2661A;">PImage</span> start, background, paper, book, copy, speechbubble, frog, dementor, werewolf,
griffin, hat, witch, dobby, rat, voldemort, owl, snitch, goodpotion1, goodpotion2, goodpotion3,
endpotion1, endpotion2, endpotion3, endpotion4, endpotion5, endpotion6, endpotion7,
endpotion8, endpotion9, endpotion10, endpotion11, endpotion12, endpotion13,
endpotion14, endpotion15;
<span style="color: #666666;">//Font Variables declared</span>
<span style="color: #E2661A;">PFont</span> font, font2; <span style="color: #666666;">//Declare PFont variable</span>
<span style="color: #666666;">// Variables for animation </span>
<span style="color: #E2661A;">int</span> numFrames = 2; <span style="color: #666666;">//The number of frames in the animation </span>
<span style="color: #E2661A;">int</span> frame = 0; <span style="color: #666666;">//Frame variable which will be used to distinguish the pace of the animation </span>
<span style="color: #E2661A;">PImage</span>[] room = <span style="color: #33997E;">new</span> <span style="color: #E2661A;">PImage</span>[numFrames]; <span style="color: #666666;">//Image array for the cauldron animation</span>
<span style="color: #E2661A;">PImage</span>[] snape = <span style="color: #33997E;">new</span> <span style="color: #E2661A;">PImage</span>[numFrames]; <span style="color: #666666;">//Image array for Snape blinking</span>
<span style="color: #666666;">//Potions</span>
<span style="color: #E2661A;">boolean</span> showImage = <span style="color: #33997E;">true</span>; <span style="color: #666666;">//The ingredient potions appearing is true but will disappear once set to "false"</span>
<span style="color: #E2661A;">boolean</span> showImage2 = <span style="color: #33997E;">true</span>;
<span style="color: #E2661A;">boolean</span> showImage3 = <span style="color: #33997E;">true</span>;
<span style="color: #E2661A;">boolean</span> showImage4 = <span style="color: #33997E;">true</span>;
<span style="color: #E2661A;">boolean</span> showImage5 = <span style="color: #33997E;">true</span>;
<span style="color: #E2661A;">boolean</span> showImage6 = <span style="color: #33997E;">true</span>;
<span style="color: #E2661A;">int</span> combination1 = 0; <span style="color: #666666;">//Combination integers which is used to create a mixture for 2 potions</span>
<span style="color: #E2661A;">int</span> combination2 = 0;
<span style="color: #E2661A;">int</span> combination3 = 0;
<span style="color: #E2661A;">int</span> combination4 = 0;
<span style="color: #E2661A;">int</span> combination5 = 0;
<span style="color: #E2661A;">int</span> combination6 = 0;
<span style="color: #E2661A;">PImage</span> potion1, potion2, potion3, <span style="color: #666666;">//Creating variables for the potions images</span>
potion4, potion5, potion6;
<span style="color: #E2661A;">int</span> lives = 4; <span style="color: #666666;">//Lives will start at 4</span>
</pre></div>
<div class="code3 grid_10">
<p id="code3_text">Interactivity + Combinations</p><pre>
<span style="color: #666666;">//If the key is pressed this fuction will activate in a loop</span>
<span style="color: #33997E;">void</span> <span style="color: #006699;"><b>keyPressed</b></span>() {
<span style="color: #669900;">if</span> (<span style="color: #D94A7A;">key</span> == <span style="color: #7D4793;">' '</span> && currentScreen == 0 ||<span style="color: #D94A7A;">key</span> == <span style="color: #7D4793;">' '</span> && currentScreen == 1) { <span style="color: #666666;">//If Spacebar is pressed and currentScreen is 0 OR 1 </span>
currentScreen++; <span style="color: #666666;">//Then currentScreen will add 1 and move on to the next currentScreen </span>
}
<span style="color: #669900;">if</span> (<span style="color: #D94A7A;">key</span> == <span style="color: #7D4793;">' '</span> && currentScreen == 4 ||<span style="color: #D94A7A;">key</span> == <span style="color: #7D4793;">' '</span> && currentScreen == 5 <span style="color: #666666;">//If Spacebar is pressed and currentScreen is 4 OR 5 OR 6 OR 7 </span>
||<span style="color: #D94A7A;">key</span> == <span style="color: #7D4793;">' '</span> && currentScreen == 6 || <span style="color: #D94A7A;">key</span> == <span style="color: #7D4793;">' '</span> && currentScreen == 7 ) {
currentScreen = 2; <span style="color: #666666;">//then it will go back to screen 2</span>
reset(); <span style="color: #666666;">//And reset variable will activate</span>
}
}
<span style="color: #666666;">//end of loop</span>
<span style="color: #33997E;">void</span> <span style="color: #006699;"><b>mousePressed</b></span>() {
<span style="color: #666666;">//If the currentScreen is equal to 3 and the mouse is pressed is in the accordinates below then </span>
<span style="color: #669900;">if</span> (currentScreen == 3 ) {
<span style="color: #669900;">if</span> ((<span style="color: #D94A7A;">mouseX</span> > 610 && <span style="color: #D94A7A;">mouseX</span> < 750) && (<span style="color: #D94A7A;">mouseY</span> > 90 && <span style="color: #D94A7A;">mouseY</span> < 450)) {
currentScreen = 4; <span style="color: #666666;">//the currentScreen changes to 4 </span>
playing = <span style="color: #33997E;">false</span>; <span style="color: #666666;">//and playing is false</span>
{
slurp=minim.loadFile(soundeffect3); <span style="color: #666666;">//The music is playing on loop and turns playing on so that it will constantly play when this setting is active </span>
slurp.play();
playing=<span style="color: #33997E;">true</span>;
}
}
}
<span style="color: #666666;">//If the currentScreen is equal to 4 and the combinations are equal to numbers outlined before then the currentScreen will be re-directed </span>
<span style="color: #669900;">if</span> ( currentScreen == 4) {
<span style="color: #666666;">//Directing the the right combination</span>
<span style="color: #669900;">if</span> ((combination4 + combination6) == 10) currentScreen = 5;
<span style="color: #669900;">if</span> ((combination5 + combination6) == 11) currentScreen = 7;
<span style="color: #669900;">if</span> ((combination2 + combination5) == 7) currentScreen = 6;
}
<span style="color: #666666;">//If the currentScreen is equal to 2 the images will dissapear based on the co-ordinates that were clicked. The music will also play and combination variables will be assigned a number </span>
<span style="color: #666666;">//which will give us the ability to use them when creating the different images to appear s</span>
<span style="color: #666666;">//ROW 1//</span>
<span style="color: #669900;">if</span> (currentScreen == 2) { <span style="color: #666666;">//If current screen is equal to 2 </span>
<span style="color: #669900;">if</span> ((<span style="color: #D94A7A;">mouseX</span> > 550 && <span style="color: #D94A7A;">mouseX</span> < 640) && (<span style="color: #D94A7A;">mouseY</span> > 80 && <span style="color: #D94A7A;">mouseY</span> < 240)) { <span style="color: #666666;">//And the mouse clicks on the places outlined </span>
showImage = !showImage; <span style="color: #666666;">//The image disappears when clicked</span>
combination1 = 1; <span style="color: #666666;">//The combination will equal to the number outlined</span>
playing = <span style="color: #33997E;">false</span>; <span style="color: #666666;">//Playing will turn to false</span>
{
bubbling=minim.loadFile(soundeffect); <span style="color: #666666;">//The music is playing on loop and turns playing on so that it will constantly play when this setting is active </span>
bubbling.play();
playing=<span style="color: #33997E;">true</span>;
}
}
<span style="color: #669900;">if</span> ((<span style="color: #D94A7A;">mouseX</span> > 650 && <span style="color: #D94A7A;">mouseX</span> < 740) && (<span style="color: #D94A7A;">mouseY</span> > 85 && <span style="color: #D94A7A;">mouseY</span> < 240)) { <span style="color: #666666;">//And the mouse clicks on the places outlined </span>
showImage2 = !showImage2; <span style="color: #666666;">//The image disappears when clicked</span>
combination2 = 2; <span style="color: #666666;">//The combination will equal to the number outlined</span>
playing = <span style="color: #33997E;">false</span>; <span style="color: #666666;">//Playing will turn to false</span>
{
bubbling=minim.loadFile(soundeffect); <span style="color: #666666;">//The music is playing on loop and turns playing on so that it will constantly play when this setting is active </span>
bubbling.play();
playing=<span style="color: #33997E;">true</span>;