-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNLN.pde
executable file
·1892 lines (1441 loc) · 52.3 KB
/
NLN.pde
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
import ddf.minim.*;
import proxml.*;
import oscP5.*;
import netP5.*;
import processing.video.*;
import java.util.UUID;
import java.awt.Desktop;
//Phone interface
int numOfButtons;
Button[] buttonsArray = new Button[1];//create the array class and add a new object to it
TextField textField1; // create a new textfield class
String letters = ""; // initial string for the text field.
//Defining classes, namespaces and globals
XMLInOut xmlIO;
OscP5 oscP5;
NetAddress myRemoteLocation;
proxml.XMLElement xml_areas;
Minim minim;
int rHN = 10000; //ReallyHighNumber - Just used where very many oportunities are needed.
Area murderArea;
Actor murderer;
PFont font;
String uniqueID; //Holder for unique identificator, used to log the number of players and time they play
int gameCount; // Count the number of turns the users play
Actor chargedSusp;
Area checkArea;
String resultText;
//Holders for game critical objects
Actor[] actors;
Area[][] areas;
Control c;
OSCSender oscS;
Analytics an;
// Variables for the textfeed
ArrayList textfeed;
int textfeedNr;
int turncounter;
int murdernum;
// Game mode switches
boolean simulationMode;
boolean videoMode;
boolean gameWindow;
// Global variables for interaction
String nettAddr = "localhost";
boolean officeMode = true;
boolean doorClicked;
boolean whiskeyClicked;
boolean radioClicked;
boolean phoneClicked;
boolean gunClicked;
boolean diceClicked;
boolean magClicked;
boolean radioMode;
boolean phoneMode;
boolean investigateMode;
boolean endScreen;
boolean importantHolder;
boolean chargeSuspects;
boolean suspectChosen;
boolean winScreen;
boolean looseScreen;
String importantText;
String instructionText;
String chargeText;
boolean dialMode;
boolean fadeMode;
int fadeCounter;
int radioCounter;
int phoneCounter;
int buttonCounter;
int gunCounter;
int whiskyCounter;
int doorCounter;
int diceCounter;
int magCounter;
//Filter controllers
boolean main_filter;
boolean click_filter;
boolean map_filter;
boolean text_filter;
boolean bottom_filter;
//Tracks the number of times an object has been clicked
int phoneNum;
int radioNum;
int gunNum;
int doorNum;
int suspNum;
int gridNum;
int whiskeyNum;
int suspectsFound;
boolean neighbourTresh;
boolean whiskeyTresh;
boolean suspectTresh;
//Escape sequence EndScreen Statistics
boolean esc_ea;
//Sets variables, can be changed, but will cause lots of frustration
static boolean debugMode = false; //Turn on and off debug mode to find errors in progra
static int memorynum = 24; //Number of turns being memory of objects
static int gsx = 16; // Gridsize vertically
static int gsy = 16; //Gridsize horisontally
static int numSusp = 5; //Numbers of Suspects __!! DO NOT CHANGE (automatic is not implemented in current version)
static int numVict = 3; //Numbers of Victims __ !! DO NOT CHANGE (automatic is not implemented in current version)
//Tempoary local solution for creating names -- Can be replaced with an XML tool
String[] victNames = new String[]{"Aunti","Oma","Granny"} ;
String[] suspNames = new String[]{"Trevor","Hugo","Christos","Marie","Mrs Rafferty"} ;
color[] suspTrace = new color[] { color(57,60,144,255),color(232,122,227,255),color(247,67,67,255),color(27,167,49,255),color(148,26,173,255) };
PImage[] suspPics;
PImage[] suspPics_lg;
//Click locations
int offsetX = 1030; //Ofset Map
//Phone
float x1 = 27;
float y1 = 303;
float w1 = 197;
float h1 = 147;
//Radio
float x2 = 414;
float y2 = 273;
float w2 = 186;
float h2 = 103;
//Door
float x3 = 507;
float y3 = 48;
float w3 = 236;
float h3 = 225;
//Gun
float x4 = 339;
float y4 = 393;
float w4 = 374;
float h4 = 88;
//Whiskey
float x5 = 296;
float y5 = 112;
float w5 = 112;
float h5 = 287;
//Magnifying Glass
float x6 = 715;
float y6 = 425;
float w6 = 125;
float h6 = 135;
//Dice
float x7 = 664;
float y7 = 481;
float w7 = 43;
float h7 = 27;
//Important holder
float ex1 = 140;
float ey1 = 50;
float eh1 = 750;
float ew1 = 300;
//DialFrame
float ex2 = 470;
float ey2 = 0;
float eh2 = 288;
float ew2 = 288;
//Total size of gameframe
static int frameWidth = 1430;
static int frameHeight = 676;
//Holders for visual content
int backgroundCounter;
PImage[] backgrounds;
PImage[] phoneBackgrounds;
PImage[] gunBackgrounds;
PImage[] whiskyBackgrounds;
PImage[] doorBackgrounds;
PImage[] diceBackgrounds;
PImage[] magBackgrounds;
PImage gridVisited;
PImage gridUnvisited;
PImage radio;
PImage phone;
PImage radioText;
PImage drawMap;
PImage nycMap;
PImage victim;
PImage eyes;
PImage ears;
PImage microphones;
PImage textfeedholder;
PImage question;
PImage toolbar;
//Holders for various fontsizes / sets
PFont bigFont;
PFont mediumFont;
PFont smallFont;
/*
Let the game begin
*/
void setup(){
/*
Loads the program
*/
//Sends signal to OS to open the max patch. Require runtime installed on users computer
try{
String here = sketchPath("");
Desktop.getDesktop().open(new File(here+"/data/NLN_AudioProg.mxf"));
} catch(Exception e){
println(e);
}
//loads the xml file for areas
xmlIO = new XMLInOut(this);
try {
xml_areas = xmlIO.loadElementFrom("data/areas.xml");
//xmlIO.loadElement("data/actors.xml");
} catch (Exception e) {
println("UNABLE TO LOAD XML DATAFILES. WILL CRASH");
exit();
}
//Sets the modes and do startup thing
simulationMode = true; //Starts in simulation mode
//Sets the click points to false - no one is clicking them
doorClicked = false;
radioClicked = false;
phoneClicked = false;
gunClicked = false;
whiskeyClicked = false;
doorClicked = false;
magClicked = false;
diceClicked = false;
radioMode = false;
phoneMode = false;
investigateMode = false;
//Sets the filters to false
main_filter = false;
map_filter = false;
text_filter = false;
bottom_filter = false;
click_filter = false;
//Set game action texts to empty and objects to null
instructionText = "";
chargeText = "";
resultText = "";
chargedSusp = null;
checkArea = null;
//Loads the possibiity to control textfeed with mousewheel
addMouseWheelListener(new java.awt.event.MouseWheelListener() {
public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
mouseWheel(evt.getWheelRotation());
}});
//Initialise sound network controller
oscS = new OSCSender(this);
//Initialises the textfeed
textfeed = new ArrayList(); textfeed.add("Welcome to the Non-linear Narrative. Please look around");
textfeedNr = 0;
// Loading game logic
int turncounter = 0; //Reset the turn counter
c = new Control();
c.createAreas();
c.createActors();
//Initialise Analytic tools
UUID tempUniqueID = UUID.randomUUID();
uniqueID = String.valueOf(tempUniqueID);
an = new Analytics();
println("Gamelogic generated, loading content data");
size(frameWidth,frameHeight);
frameRate(10);
// Reads backgrounds
backgrounds = new PImage[10];
backgroundCounter = 0;
for(int i = 0; i < 10; i++){
backgrounds[i] = loadImage("data/backgrounds/bg"+(i+1)+".jpg");
}
gunCounter = 0;
gunBackgrounds = new PImage[37];
for(int i = 0; i < 37; i++){
gunBackgrounds[i] = loadImage("data/backgrounds/gun"+(i+1)+".jpg");
}
suspPics = new PImage[5];
for(int i = 0; i < 5; i++){
suspPics[i] = loadImage("data/susp"+(i+1)+".jpg");
}
suspPics_lg = new PImage[5];
for(int i = 0; i < 5; i++){
suspPics_lg[i] = loadImage("data/susp"+(i+1)+"_lg.jpg");
}
whiskyBackgrounds = new PImage[19];
for(int i = 0; i < 19; i++){
whiskyBackgrounds[i] = loadImage("data/backgrounds/Whisky"+(i+1)+".jpg");
}
diceBackgrounds = new PImage[38];
for(int i = 0; i < 38; i++){
diceBackgrounds[i] = loadImage("data/backgrounds/Dice"+(i+1)+".jpg");
}
magBackgrounds = new PImage[19];
for(int i = 0; i < 19; i++){
magBackgrounds[i] = loadImage("data/backgrounds/MAG"+(i+1)+".jpg");
}
toolbar = loadImage("data/toolbar.jpg");
phoneBackgrounds = new PImage[20];
phoneCounter = 0;
for(int i = 0; i < phoneBackgrounds.length; i++){
phoneBackgrounds[i] = loadImage("data/backgrounds/phone"+(i+1)+".jpg");
}
radioText = loadImage("data/Meanwhile.png");
radio = loadImage("data/radio.jpg");
phone = loadImage("data/phone.jpg");
drawMap = loadImage("data/bgmapHand.jpg");
ears = loadImage("data/ear.png");
eyes = loadImage("data/eye.png");
question = loadImage("data/question.jpg");
textfeedholder = loadImage("data/textframe.jpg");
gridVisited = loadImage("data/grid_visited.jpg");
gridUnvisited = loadImage("data/grid_unvisited.jpg");
//This is rather silly, but finds a random generated font -- Temporary, and here because of problems with intercompability of fonts
String[] fontlist = PFont.list();
font = createFont(fontlist[int(random(5))], 10);
buttonCounter = 0;
// bigFont = loadFont("Type-Ra-16.vlw");
// mediumFont = loadFont("Type-Ra-14.vlw");
// smallFont = loadFont("Type-Ra-12.vlw");
print("Altering the last variables...");
//Sets number val
phoneNum = 0;
radioNum = 0;
gunNum = 0;
doorNum = 0;
suspNum = 0;
gridNum = 0;
doorNum = 0;
whiskeyNum = 0;
fadeCounter = 0;
// Set analytic tresholds to false
neighbourTresh = false;
suspectTresh = false;
whiskeyTresh = false;
// Sets last logic
chargeSuspects = false;
winScreen = false;
looseScreen = false;
dialMode = false;
fadeMode = false;
//Escape sequence EndScreen Statistics
esc_ea = true;
// Seeds the events
c.runsimulation();
// Starts game window
gameWindow = true;
println(".... and we are good to go!");
smooth();
// For phone method
// Inputs: letters, xpos, ypos, xsize, ysize
textField1 = new TextField("",500, 213-53*4,53*4,53*2,c);
// Inputs: command, label, posX, posY, size, base color, over color, press color
Button button1 = new Button("1","1", 477,224-53*2, 53, color(50), color(70), color(90));
Button button2 = new Button("2","2",529, 224-53*2, 53,color(50), color(70), color(90));
Button button3 = new Button("3","3",583, 224-53*2, 53,color(50), color(70), color(90));
Button button4 = new Button("4","4",636, 224-53*2, 53,color(50), color(70), color(90));
Button button5 = new Button("5","5",689, 224-53*2, 53,color(50), color(70), color(90));
Button button6 = new Button("6","6",477, 224-53, 53,color(50), color(70), color(90));
Button button7 = new Button("7","7",529, 224-53, 53,color(50), color(70), color(90));
Button button8 = new Button("8","8",583, 224-53, 53,color(50), color(70), color(90));
Button button9 = new Button("9","9",636, 224-53, 53,color(50), color(70), color(90));
Button button0 = new Button("0","0",689, 224-53, 53,color(50), color(70), color(90));
Button buttonDEL = new Button("DELETE","<",689, 224, 53,color(50), color(70), color(90));
Button buttonDECIMAL = new Button("DECIMAL",".",477, 224, 53,color(50), color(70), color(90));
// append the buttonsArray one at a time with each object
buttonsArray = (Button[]) append(buttonsArray,button1);
buttonsArray = (Button[]) append(buttonsArray,button2);
buttonsArray = (Button[]) append(buttonsArray,button3);
buttonsArray = (Button[]) append(buttonsArray,button4);
buttonsArray = (Button[]) append(buttonsArray,button5);
buttonsArray = (Button[]) append(buttonsArray,button6);
buttonsArray = (Button[]) append(buttonsArray,button7);
buttonsArray = (Button[]) append(buttonsArray,button8);
buttonsArray = (Button[]) append(buttonsArray,button9);
buttonsArray = (Button[]) append(buttonsArray,button0);
buttonsArray = (Button[]) append(buttonsArray,buttonDEL);
buttonsArray = (Button[]) append(buttonsArray,buttonDECIMAL);
}
void draw() {
background(33);
if(videoMode){
background(0);
videoMode = false;
textFont(font, 32);
String openingText = "";
//Get time of day and print appropriate introduction to the game
int timeTest = c.getHour(0);
if(timeTest<8){
openingText = "While the city was sleeping";
} else if(timeTest>=8 && timeTest < 16){
openingText = "In the middle of the day";
} else {
openingText = "The end of a busy day";
}
//Ask the sound controller to play intro
fill(255);
text(openingText,800,600);
delay(10000); // Wait for 8 seconds. Sound playing, and text on screen
oscS.sendMessage("gameStart");
} else if(endScreen) {
if(esc_ea){
an.registerEndGame();
link("http://nonlinearnarrative.org/endGame.php?gameID="+uniqueID, "_new");
}
esc_ea = false;
background(0);
textFont(font, 32);
text(resultText,200,500);
} else if(gameWindow) {
fill(0);
noStroke();
//Draws the window structure
rect(1024,0,6,frameHeight);
rect(1030,400,400,6);
rect(0,576,1024,6);
//Places images
image(drawMap,1030,0);
image(textfeedholder,1030,406);
//if(!investigateMode){
image(toolbar,0, 582);
// }
// Plays appropriate background to action
if (backgroundCounter == 10){backgroundCounter = 0;}
image(backgrounds[backgroundCounter],0,0);
backgroundCounter++;
if(phoneClicked){
if(phoneCounter == 19){phoneCounter = 0; phoneClicked = false;}
image(phoneBackgrounds[phoneCounter],0,0);
phoneCounter++;
}
if(gunClicked){
if(gunCounter == 37){gunCounter = 0; gunClicked = false;}
if(gunCounter == 22){ oscS.sendMessage("playGun");}
image(gunBackgrounds[gunCounter],0,0);
gunCounter++;
}
if(whiskeyClicked){
if(whiskyCounter == 17){whiskyCounter = 0; whiskeyClicked = false;}
image(whiskyBackgrounds[whiskyCounter],0,0);
println("WhiskeyNr: "+whiskyCounter);
whiskyCounter++;
}
if(diceClicked){
if(diceCounter == 38){diceCounter = 0; diceClicked = false;}
image(diceBackgrounds[diceCounter],0,0);
println("DiceNr: "+diceCounter);
diceCounter++;
}
if(magClicked){
if(magCounter == 18){magCounter = 0; magClicked = false;}
image(magBackgrounds[magCounter],0,0);
println("MagNr: "+magCounter);
magCounter++;
}
// Draws the side panels
if(radioMode){
image(radio,750,0);
}
if(phoneMode){
image(phone,750,0);
}
// Checks treshold and call updates
if(!suspectTresh){
int localTest = 0;
for(int i = 0; i<numSusp; i++){
if (actors[i].known){
localTest++;
}
}
if(localTest == 5 ){
suspectTresh = true;
oscS.sendMessage("foundSuspect");
an.registerFoundSuspects();
}
}
if(!whiskeyTresh){
if(whiskeyNum == 5){
an.registerGotDrunk();
whiskeyTresh = true;
}
}
if(!neighbourTresh){
if(gunNum == 3){
an.registerScaredNeighbour();
neighbourTresh = true;
}
}
fill(0,255,0);
textFont(font);
text(c.gettime(0),15,15);
text(instructionText,100,15);
fill(255);
//Draws the cardiographic image according to activity known in area
if(investigateMode){
for(int i = 0; i < 23; i++){
boolean visitor = false;
for(int j = 0; j< numSusp+numVict; j++){
if(actors[j].memory[(turncounter-24)+i] == checkArea){visitor = true;}
}
if(visitor){
image(gridVisited,30+(i*42),582);
} else{
image(gridUnvisited,30+(i*42),582);
}
}
}
for(int i= 0; i<numSusp; i++){
fill(255);
if(actors[i].known){
fill(0,266,0);
stroke(color(15));
}
if(actors[i].known) image(suspPics[i], 15, 20+62*i);
}
noStroke();
for(int i=0; i < gsx; i++){
for(int j=0; j <gsy; j++){
//Code under marks if microphones or cameras are in place
Area a = areas[i][j];
if(a.heard){
fill(255,0,255,60);
noStroke();
rect(offsetX+i*25,j*25,25,25);
}
if(a.seen){
fill(255,255,255,90);
noStroke();
rect(offsetX+i*25,j*25,25,25);
}
if(a.mic == true){
image(ears,offsetX+i*25,j*25,25,25);
}
if(a.cam == true){
image(eyes,offsetX+i*25,j*25,25,25);
}
if(a == checkArea){
fill(0,0,255,100);
rect(offsetX+i*25,j*25,25,25);
}
}
}
fill(0,0,0);
stroke(200,200,200);
/*
Textbox function. Fill the textbox with the last sentences from the textfeed and print them on to the screen
*/
int textOffsetX = 1030 + 5 ;
int textOffsetY = 406 + 20 ;
int textspacing = 14 ;
textFont(font);
textAlign(LEFT);
for(int texti = 0; texti < 18; texti++){
if(texti < textfeed.size()){
String textstring;
try {
if(textfeed.size() > 18){
textstring = textfeed.get((textfeed.size() - (texti +1) - textfeedNr)).toString();
} else {
textstring = textfeed.get((textfeed.size() - (texti +1) )).toString();
}
text(textstring,textOffsetX ,((textspacing*texti)+textOffsetY));
} catch (Exception e){
//Whoops
}
}
}
//Filter fuctions - To impose a new focal point for the player
fill(0,0,0,150);
if(main_filter) rect(0,0,1024,576);
if(map_filter) rect(1030,0,400,400);
if(text_filter) rect(1030,406,400,height-406);
if(bottom_filter) rect(0,582,1024,height-582);
if(click_filter) rect(0,0,1024-270,576);
/*
Important holder is the in screen interface which appears when all five suspects are found, and can be prosecuted.
*/
if(importantHolder){ // Opens the imporantHolder and Halts game
main_filter = true;
map_filter = true;
text_filter = true;
bottom_filter = true;
fill(33);
rect(140,50,750,300);
if(chargeSuspects){
importantText = "Who is the murderer? ";
for(int i = 0; i<numSusp; i++){
image(suspPics_lg[i], 140+((i*150)), 60);
fill(255);
text(importantText,150,230);
text(chargeText,150,260);
text(resultText,150,300);
}
} else {
//Should not be here
}
} else if(dialMode){
rect(465,0,288,288);
textField1.display();
// loop through all the button objects and run update and display functions.
for(int i=1; i<buttonsArray.length; i++){
buttonsArray[i].update();
buttonsArray[i].display();
}
noStroke();
fill(50);
} else {
// do nothing
}
} else {
//Not here either
}
} //End of method draw()
void mousePressed() {
{
// loop through ALL the objects and run press on buttons and return values for all buttons to textField object.
for(int i=1; i<buttonsArray.length; i++){
buttonsArray[i].press();
textField1.textInput(buttonsArray[i].output());
}
}
/* Holder to display text within the main frame */
if(importantHolder){
if(mouseButton == LEFT){
if(mouseX>0 && mouseX<width && mouseY>0 && mouseY<height){ //Checks that click is within gameframe
boolean inside = true;
if(mouseX>140 && mouseX<140+750 && mouseY>50 && mouseY<50+300){
inside = true;
} else {
inside = false;
}
//If click is outside the frame. Goes back to game
if(!inside){
importantHolder = false;
main_filter = false;
map_filter = false;
text_filter = false;
bottom_filter = false;
click_filter = false;
} else{
int picOutsetX = 140;
int picSize = 150;
if(mouseX>picOutsetX && mouseX<picOutsetX+picSize && mouseY>60 && mouseY < 60+picSize){
if(actors[0] == murderer && chargedSusp == actors[0]){ println("You nailed that bastard!"); oscS.sendMessage("solvedGame/right"); resultText = "You chose the right person. "+actors[0].name+" was the killer"; endScreen = true;
} else if(actors[0] != murderer && chargedSusp == actors[0]){resultText = "You chose the wrong person. "+ murderer.name+" was the killer"; endScreen = true; oscS.sendMessage("solvedGame/wrong");}
chargeText = "You charged - Click to confirm: "+actors[0].name; oscS.sendMessage("phoneResult/confirm");
chargedSusp = actors[0];
} else if(mouseX>picOutsetX+picSize && mouseX<picOutsetX+(picSize*2) && mouseY>60 && mouseY < 60+picSize){
if(actors[1] == murderer && chargedSusp == actors[1]){ println("You nailed that bastard!"); oscS.sendMessage("solvedGame/right"); resultText = "You chose the right person. "+actors[1].name+" was the killer"; endScreen = true;
} else if(actors[1] != murderer && chargedSusp == actors[1]){resultText = "You chose the wrong person. "+ murderer.name+" was the killer"; endScreen = true; oscS.sendMessage("solvedGame/wrong");}
chargeText = "You charged - Click to confirm: "+actors[1].name; oscS.sendMessage("phoneResult/confirm");
chargedSusp = actors[1];
} else if(mouseX>picOutsetX+(picSize*2) && mouseX<picOutsetX+(picSize*3) && mouseY>60 && mouseY < 60+picSize){
if(actors[2] == murderer && chargedSusp == actors[2]){ println("You nailed that bastard!"); oscS.sendMessage("solvedGame/right");resultText = "You chose the right person. "+actors[2].name+" was the killer"; endScreen = true;
} else if(actors[2] != murderer && chargedSusp == actors[2]){resultText = "You chose the wrong person. "+ murderer.name+" was the killer"; endScreen = true; oscS.sendMessage("solvedGame/wrong");}
chargeText = "You charged - Click to confirm: "+actors[2].name; oscS.sendMessage("phoneResult/confirm");
chargedSusp = actors[2];
} else if(mouseX>picOutsetX+(picSize*3) && mouseX<picOutsetX+(picSize*4) && mouseY>60 && mouseY < 60+picSize){
if(actors[3] == murderer && chargedSusp == actors[3]){ println("You nailed that bastard!"); oscS.sendMessage("solvedGame/right");resultText = "You chose the right person. "+actors[3].name+" was the killer"; endScreen = true;
} else if(actors[3] != murderer && chargedSusp == actors[3]){resultText = "You chose the wrong person. "+ murderer.name+" was the killer"; endScreen = true; oscS.sendMessage("solvedGame/wrong");}
chargeText = "You charged - Click to confirm: "+actors[3].name; oscS.sendMessage("phoneResult/confirm");
chargedSusp = actors[3];
} else if(mouseX>picOutsetX+(picSize*4) && mouseX<picOutsetX+(picSize*5) && mouseY>60 && mouseY < 60+picSize){
if(actors[4] == murderer && chargedSusp == actors[4]){ println("You nailed that bastard!"); oscS.sendMessage("solvedGame/right");resultText = "You chose the right person. "+actors[4].name+" was the killer"; endScreen = true;
} else if(actors[4] != murderer && chargedSusp == actors[4]){resultText = "You chose the wrong person. "+ murderer.name+" was the killer"; endScreen = true; oscS.sendMessage("solvedGame/wrong");}
chargeText = "You charged - Click to confirm: "+actors[4].name; oscS.sendMessage("phoneResult/confirm");
}
}
}
}
//Shortcut version, so the user don't have to call the detective each time
} else if(dialMode){
if(mouseButton == LEFT){
if(mouseX>1030 && mouseX<1030+400 && mouseY>0 && mouseY<400){
println("Shortcut clicked");
dialMode = false;
text_filter = false;
}
}
} else {
if(mouseButton == LEFT){
//Functions are within the map sector
if(mouseX>offsetX && mouseX < offsetX+25*gsx && mouseY > 0 && mouseY < gsy*25){
if(radioMode) {
areas[(mouseX-offsetX)/25][mouseY/25].mic = true;
buttonCounter++;
} else if(phoneMode){
areas[(mouseX-offsetX)/25][mouseY/25].cam = true;
buttonCounter++;
} else if(investigateMode){
checkArea = areas[(mouseX-offsetX)/25][mouseY/25];
}
//Counts the number of clicks by the user. 5 flicks then reRunSimulation and clear tools
if(buttonCounter > 5){
c.reRunSimulation();
gameCount++;
c.clearTools();
radioMode = false;
phoneMode = false;
main_filter = false;
text_filter = false;
bottom_filter = false;
click_filter = false;
buttonCounter = 0;
}
//Functions are
} else if(mouseX>0 && mouseX<offsetX && mouseY>0 && mouseY <1024 && !click_filter){
if(mouseX>x1 && mouseX <x1+w1 && mouseY>y1 && mouseY <y1+h1){
println("The mouse is pressed and over the phone");
phoneClicked = true;
phoneMode = true;
dialMode = true;
click_filter = true;
phoneNum++;
oscS.sendMessage("playPhone");
textfeed.add("___________***___________");
textfeed.add("Luigi's Pizza : 9136 ");
textfeed.add("Informant : 7824 ");
textfeed.add("My numbers:");
textfeed.add("___________***___________");
}
if(mouseX>x2 && mouseX <x2+w2 && mouseY>y2 && mouseY <y2+h2){
println("The mouse is pressed and over the radio");
radioClicked = true;
radioMode = true;
click_filter = true;
radioNum++;
oscS.sendMessage("playRadio");
}
if(mouseX>x3 && mouseX <x3+w3 && mouseY>y3 && mouseY <y3+h3){
println("The mouse is pressed and over the door");
if(suspectTresh){
doorClicked = true;
doorNum++;
oscS.sendMessage("playDoor");
importantHolder = true;
main_filter = true;
chargeSuspects = true;
} else {
println("Not found aditional suspects yet");
oscS.sendMessage("notFoundEnoughSuspects");
}
}
if(mouseX>x4 && mouseX <x4+w4 && mouseY>y4 && mouseY <y4+h4) {
println("Pang");
gunClicked = true;
gunNum++;
}
if(mouseX>x5 && mouseX <x5+w5 && mouseY>y5 && mouseY <y5+h5){
println("Glugg glugg");
whiskeyNum++;
whiskeyClicked = true;
oscS.sendMessage("playWhisky");
}
if(mouseX>x6 && mouseX <x6+w6 && mouseY>y6 && mouseY <y6+h6){
println("Glass is up!");
magClicked = true;
investigateMode = true;
main_filter = true;
} else if(mouseX > 0 && mouseX < offsetX && mouseY > 0 && mouseY < 758 && investigateMode){
println("Someone clicked here - Should turn off investigation");
investigateMode = false;
main_filter = false;
checkArea = null;
}
if(mouseX>x7 && mouseX <x7+w7 && mouseY>y7 && mouseY <y7+h7){
println("Let's gamble");
diceCounter++;
diceClicked = true;
oscS.sendMessage("playDice");
}
}
if(mouseX > 15 && mouseX < 75 && mouseY > 20 && mouseY < 310) { //Is within the supsect field
int tempNum = floor(mouseY / 62);
if(tempNum >= 0 && tempNum < 5){
if(actors[tempNum].known){
oscS.sendMessage("pokeSuspect"+(tempNum+1));
}
}
}
} //End of check Desk
}//End of check mouse button
//her
}//End of method
void mouseMoved(){
instructionText = "";
cursor(POINT);
if(importantHolder){
boolean inside = true;
if(mouseX>140 && mouseX<140+750 && mouseY>50 && mouseY<50+300){
inside = true;
} else {
inside = false;
}
if(inside) {
int picOutsetX = 140;
int picSize = 150;
if(mouseX>picOutsetX && mouseX<picOutsetX+picSize && mouseY>60 && mouseY < 60+picSize){
cursor(HAND);
chargeText = (String) actors[0].name;