-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFinalGame.java
1266 lines (1190 loc) · 45.2 KB
/
FinalGame.java
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
//Name: Deval Patel
//Date: June 13, 2017
//Purpose: To make the best game of Sokoban (but not really). I did what I could (please don't fail :) )
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.Applet;
import java.applet.*;
import java.lang.Object;
import java.util.Vector;
public class FinalGame extends Applet implements ActionListener, KeyListener
{
Panel p_card; //to hold all of the screens
Panel card1, card2, card3, card4, card5, card6; //the six screens
CardLayout cdLayout = new CardLayout ();
//sound
AudioClip soundFile;
//declaring global JLabels
JTextArea ins;
JLabel moves;
JLabel curlevel;
JLabel showtime;
//all starting positions for the character
int startx[] = {15, 13, 5, 11, 13, 9};
int starty[] = {14, 4, 11, 3, 16, 10};
//cur location
int curx = 15;
int cury = 14;
//undo cur location
int undox[] = new int [1000];
int undoy[] = new int [1000];
//grid
int level = 1;
int score = 0;
int row = 20;
int col = 20;
JLabel a[] = new JLabel [row * col];
//elapsed time
static int time = 0;
Thread timecount = new Thread ()
{
public void run ()
{
while (true)
{
try
{
Thread.sleep (1000);
}
catch (Exception e)
{
}
time++;
//Calculates minutes and seconds and displays it
if (time % 60 < 10)
showtime.setText ("Elapsed Time: " + time / 60 + ":0" + time % 60);
else
showtime.setText ("Elapsed Time: " + time / 60 + ":" + time % 60);
}
}
}
;
//Undo Array
int undo[] [] [] = new int [1000] [row] [col];
int where = -1;
//MAIN GRID
//array which changes
int b[] [] = {{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 1, 3, 3, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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 3, 4, 3, 1, 1, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 1, 1, 3, 4, 3, 1, 1, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 1, 1, 3, 4, 3, 4, 3, 1, 1, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 1, 1, 3, 4, 3, 4, 3, 4, 3, 1, 1, 2, 2, 2, 2},
{2, 2, 2, 2, 1, 1, 3, 4, 3, 4, 3, 4, 3, 4, 3, 1, 1, 2, 2, 2},
{2, 2, 2, 1, 1, 3, 3, 3, 4, 3, 4, 3, 4, 3, 3, 3, 1, 1, 2, 2},
{2, 2, 1, 1, 3, 3, 3, 3, 3, 4, 3, 4, 3, 3, 3, 3, 3, 1, 1, 2},
{2, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1},
{2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}};
public void init ()
{
addKeyListener (this);
soundFile = getAudioClip (getDocumentBase (), "despacito.wav");
//this attaches the sound file "despacito"
soundFile.loop ();
//put the sound on repeat
p_card = new Panel ();
p_card.setLayout (cdLayout);
storemove ();
screen1 ();
screen2 ();
screen3 ();
screen4 ();
screen5 ();
screen6 ();
resize (750, 565);
setLayout (new BorderLayout ());
add ("Center", p_card);
}
public void screen1 ()
{ //screen 1 is set up.
card1 = new Panel ();
card1.setBackground (new Color (80, 130, 160));
//main menu pic
JButton pic = new JButton (createImageIcon ("sokoban title screen.jpg"));
//title button
pic.setActionCommand ("s2");
pic.addActionListener (this);
pic.setBorderPainted (false);
pic.setPreferredSize (new Dimension (750, 565));
card1.add (pic);
p_card.add ("1", card1);
}
public void screen2 ()
{ //screen 2 is set up.
card2 = new Panel ();
card2.setBackground (new Color (80, 130, 160));
//title of the screen
JLabel title = new JLabel (createImageIcon ("ins title.png"));
//Next button
JButton next = new JButton ("Next");
next.setForeground (new Color (46, 76, 119));
next.setBackground (new Color (179, 205, 216));
next.setPreferredSize (new Dimension (100, 50));
next.setOpaque (true);
next.setBorder (BorderFactory.createLineBorder (Color.black));
next.setActionCommand ("s3");
next.addActionListener (this);
//Instructions
JLabel ins = new JLabel (createImageIcon ("instructions.fw.png"));
card2.add ("North", title);
card2.add ("Center", ins);
card2.add ("South", next);
p_card.add ("2", card2);
}
public void screen3 ()
{
timecount.start ();
//screen 3 is set up.
card3 = new Panel (new BorderLayout ());
card3.setBackground (new Color (80, 130, 160));
//title
JLabel title = new JLabel ("Sokoban", SwingConstants.CENTER);
title.setFont (new Font ("Serif", Font.BOLD, 36));
title.setPreferredSize (new Dimension (1000, 50));
title.setForeground (Color.white);
//Moves
moves = new JLabel ("Moves: " + score);
moves.setFont (new Font ("Garamond", Font.BOLD, 20));
moves.setPreferredSize (new Dimension (1000, 50));
moves.setForeground (Color.black);
//Level Label
curlevel = new JLabel ("Level: " + level);
curlevel.setFont (new Font ("Garamond", Font.BOLD, 20));
curlevel.setPreferredSize (new Dimension (1000, 50));
curlevel.setForeground (Color.black);
//Instructions
ins = new JTextArea ("Use arrow keys ");
ins.append ("\n");
ins.append ("or Use W, A, S, D");
ins.setFont (new Font ("Garamond", Font.BOLD, 20));
ins.setPreferredSize (new Dimension (1000, 50));
ins.setForeground (Color.black);
ins.setBackground (new Color (80, 130, 160));
// Elapsed Time
showtime = new JLabel ("Elapsed Time: " + time / 60 + ": " + time % 60);
showtime.setFont (new Font ("Garamond", Font.BOLD, 20));
//next button
JButton next = new JButton ("Next");
next.setForeground (new Color (46, 76, 119));
next.setBackground (new Color (179, 205, 216));
next.setPreferredSize (new Dimension (100, 50));
next.setBorder (BorderFactory.createLineBorder (Color.black));
next.setActionCommand ("s4");
next.addActionListener (this);
//reset button
JButton reset = new JButton ("Reset");
reset.setForeground (new Color (46, 76, 119));
reset.setBackground (new Color (179, 205, 216));
reset.setPreferredSize (new Dimension (100, 50));
reset.setBorder (BorderFactory.createLineBorder (Color.black));
reset.setActionCommand ("reset");
reset.addActionListener (this);
//undo button
JButton undo = new JButton ("Undo");
undo.setForeground (new Color (46, 76, 119));
undo.setBackground (new Color (179, 205, 216));
undo.setPreferredSize (new Dimension (100, 50));
undo.setBorder (BorderFactory.createLineBorder (Color.black));
undo.setActionCommand ("undo");
undo.addActionListener (this);
//Level select button
JButton lvlselect = new JButton ("Levels");
lvlselect.setForeground (new Color (46, 76, 119));
lvlselect.setBackground (new Color (179, 205, 216));
lvlselect.setPreferredSize (new Dimension (100, 50));
lvlselect.setBorder (BorderFactory.createLineBorder (Color.black));
lvlselect.setActionCommand ("lvls");
lvlselect.addActionListener (this);
// up button
JButton up = new JButton ("Up");
up.setForeground (new Color (46, 76, 119));
up.setBackground (new Color (179, 205, 216));
up.setActionCommand ("up");
up.addActionListener (this);
// down button
JButton down = new JButton ("Down");
down.setForeground (new Color (46, 76, 119));
down.setBackground (new Color (179, 205, 216));
down.setActionCommand ("down");
down.addActionListener (this);
// right button
JButton right = new JButton ("Right");
right.setForeground (new Color (46, 76, 119));
right.setBackground (new Color (179, 205, 216));
right.setActionCommand ("right");
right.addActionListener (this);
// left button
JButton left = new JButton ("Left");
left.setForeground (new Color (46, 76, 119));
left.setBackground (new Color (179, 205, 216));
left.setActionCommand ("left");
left.addActionListener (this);
// empty buttons
JButton empty1 = new JButton ("");
empty1.setBackground (new Color (80, 130, 160));
empty1.setBorderPainted (false);
empty1.setEnabled (false);
JButton empty2 = new JButton ("");
empty2.setBackground (new Color (80, 130, 160));
empty2.setBorderPainted (false);
empty2.setEnabled (false);
JButton empty3 = new JButton ("");
empty3.setBackground (new Color (80, 130, 160));
empty3.setBorderPainted (false);
empty3.setEnabled (false);
JButton empty4 = new JButton ("");
empty4.setBackground (new Color (80, 130, 160));
empty4.setBorderPainted (false);
empty4.setEnabled (false);
JButton empty5 = new JButton ("");
empty5.setBackground (new Color (80, 130, 160));
empty5.setBorderPainted (false);
empty5.setEnabled (false);
//Set up grid
Panel p = new Panel (new GridLayout (row, col));
int move = 0;
//makes the grid for the first time
for (int i = 0 ; i < row ; i++)
{
for (int j = 0 ; j < col ; j++)
{
a [move] = new JLabel (createImageIcon (b [i] [j] + ".jpg"));
a [move].setPreferredSize (new Dimension (24, 24));
p.add (a [move]);
move++;
}
}
a [curx * col + cury].setIcon (createImageIcon ("6.jpg"));
card3.add ("North", title);
//Panel for level, moves and instructions
Panel p6 = new Panel (new GridLayout (4, 1));
p6.add (curlevel);
p6.add (moves);
p6.add (ins);
p6.add (showtime);
//Panel for formatting
Panel p3 = new Panel (new GridLayout (3, 1));
p3.add (p6);
card3.add ("West", p);
//Panel for important buttons
Panel p1 = new Panel (new GridLayout (2, 2));
p1.add (next);
p1.add (reset);
p1.add (undo);
p1.add (lvlselect);
Panel p5 = new Panel ();
p5.add (p1);
//panel for direction arrows
Panel p4 = new Panel ();
Panel p2 = new Panel (new GridLayout (3, 3));
p2.add (empty1);
p2.add (up);
p2.add (empty2);
p2.add (left);
p2.add (empty3);
p2.add (right);
p2.add (empty4);
p2.add (down);
p2.add (empty5);
p4.add (p2);
p3.add (p4);
p3.add (p5);
card3.add ("Center", p3);
p_card.add ("3", card3);
setFocusable (true);
}
public void screen4 ()
{ //screen 4 is set up.
card4 = new Panel ();
card4.setBackground (Color.black);
JLabel title = new JLabel (createImageIcon ("wintitle.jpg"));
title.setPreferredSize (new Dimension (750, 265));
JButton next = new JButton (createImageIcon ("lvlselect.jpg"));
next.setActionCommand ("s5");
next.addActionListener (this);
next.setPreferredSize (new Dimension (750, 150));
next.setBorder (BorderFactory.createLineBorder (Color.black));
JButton quit = new JButton (createImageIcon ("quit.jpg"));
quit.setActionCommand ("quit");
quit.addActionListener (this);
quit.setPreferredSize (new Dimension (750, 150));
quit.setBorder (BorderFactory.createLineBorder (Color.black));
card4.add (title);
card4.add (next);
card4.add (quit);
p_card.add ("4", card4);
}
public void screen5 ()
{ //screen 5 is set up.
card5 = new Panel ();
card5.setBackground (Color.black);
//title
JLabel title = new JLabel (createImageIcon ("losetitle.jpg"));
title.setPreferredSize (new Dimension (750, 265));
//Next button, goes to intro
JButton next = new JButton (createImageIcon ("intro.jpg"));
next.setActionCommand ("s1");
next.addActionListener (this);
next.setPreferredSize (new Dimension (750, 100));
next.setBorder (BorderFactory.createLineBorder (Color.black));
//Level Select
JButton lvl = new JButton (createImageIcon ("lvlselect2.jpg"));
lvl.setActionCommand ("lvlend");
lvl.addActionListener (this);
lvl.setPreferredSize (new Dimension (750, 100));
lvl.setBorder (BorderFactory.createLineBorder (Color.black));
//Quit button
JButton end = new JButton (createImageIcon ("quit.jpg"));
end.setActionCommand ("s6");
end.addActionListener (this);
end.setPreferredSize (new Dimension (750, 100));
end.setBorder (BorderFactory.createLineBorder (Color.black));
card5.add (title);
card5.add (next);
card5.add (lvl);
card5.add (end);
p_card.add ("5", card5);
}
public void screen6 ()
{ //screen 6 is set up. Level Select Screen
card6 = new Panel (new BorderLayout ());
card6.setBackground (new Color (80, 130, 160));
//title of the screen
JLabel title = new JLabel ("Level Select", SwingConstants.CENTER);
title.setFont (new Font ("Serif", Font.BOLD, 46));
title.setForeground (Color.white);
//blank Labels
JLabel blank = new JLabel ("");
JLabel blank2 = new JLabel ("");
JLabel blank3 = new JLabel ("");
//Level 1 button
JButton lvl1 = new JButton ("Level 1");
lvl1.setFont (new Font ("Garamond", Font.BOLD, 36));
lvl1.setForeground (new Color (46, 76, 119));
lvl1.setBackground (new Color (179, 205, 216));
lvl1.setPreferredSize (new Dimension (150, 100));
lvl1.setBorder (BorderFactory.createLineBorder (Color.black));
lvl1.setActionCommand ("level1");
lvl1.addActionListener (this);
//Level 2 button
JButton lvl2 = new JButton ("Level 2");
lvl2.setFont (new Font ("Garamond", Font.BOLD, 36));
lvl2.setForeground (new Color (46, 76, 119));
lvl2.setBackground (new Color (179, 205, 216));
lvl2.setPreferredSize (new Dimension (150, 100));
lvl2.setBorder (BorderFactory.createLineBorder (Color.black));
lvl2.setActionCommand ("level2");
lvl2.addActionListener (this);
//Level 3 button
JButton lvl3 = new JButton ("Level 3");
lvl3.setFont (new Font ("Garamond", Font.BOLD, 36));
lvl3.setForeground (new Color (46, 76, 119));
lvl3.setBackground (new Color (179, 205, 216));
lvl3.setPreferredSize (new Dimension (150, 100));
lvl3.setBorder (BorderFactory.createLineBorder (Color.black));
lvl3.setActionCommand ("level3");
lvl3.addActionListener (this);
//Level 4 button
JButton lvl4 = new JButton ("Level 4");
lvl4.setFont (new Font ("Garamond", Font.BOLD, 36));
lvl4.setForeground (new Color (46, 76, 119));
lvl4.setBackground (new Color (179, 205, 216));
lvl4.setPreferredSize (new Dimension (150, 100));
lvl4.setBorder (BorderFactory.createLineBorder (Color.black));
lvl4.setActionCommand ("level4");
lvl4.addActionListener (this);
//Level 5 button
JButton lvl5 = new JButton ("Level 5");
lvl5.setFont (new Font ("Garamond", Font.BOLD, 36));
lvl5.setForeground (new Color (46, 76, 119));
lvl5.setBackground (new Color (179, 205, 216));
lvl5.setPreferredSize (new Dimension (150, 100));
lvl5.setBorder (BorderFactory.createLineBorder (Color.black));
lvl5.setActionCommand ("level5");
lvl5.addActionListener (this);
//Level 6 button
JButton lvl6 = new JButton ("Level 6");
lvl6.setFont (new Font ("Garamond", Font.BOLD, 36));
lvl6.setForeground (new Color (46, 76, 119));
lvl6.setBackground (new Color (179, 205, 216));
lvl6.setPreferredSize (new Dimension (200, 100));
lvl6.setBorder (BorderFactory.createLineBorder (Color.black));
lvl6.setActionCommand ("level6");
lvl6.addActionListener (this);
//Panel for all lvls
Panel p1 = new Panel (new GridLayout (2, 3));
p1.add (lvl1);
p1.add (lvl2);
p1.add (lvl3);
p1.add (lvl4);
p1.add (lvl5);
p1.add (lvl6);
//Panel to format levels
Panel p4 = new Panel ();
p4.add (p1);
Panel p5 = new Panel ();
p5.add (title);
card6.add ("North", p5);
card6.add ("Center", p4);
card6.add ("South", blank);
card6.add ("East", blank2);
card6.add ("West", blank3);
p_card.add ("6", card6);
}
protected static ImageIcon createImageIcon (String path)
{ //Makes images possible
java.net.URL imgURL = FinalGame.class.getResource (path);
if (imgURL != null)
{
return new ImageIcon (imgURL);
}
else
{
System.err.println ("Couldn't find file: " + path);
return null;
}
}
public void redraw ()
{ //redraws the screen
int move = 0;
for (int i = 0 ; i < row ; i++)
{
for (int j = 0 ; j < col ; j++)
{
a [move].setIcon (createImageIcon (b [i] [j] + ".jpg"));
move++;
}
}
//sets current position
a [curx * col + cury].setIcon (createImageIcon ("6.jpg"));
}
public void newLevel (int a[] [], int c[] [], int lvl)
{ //loads a new level
//sets current to the respective level's starting position
curx = startx [lvl];
cury = starty [lvl];
//sets the grid to the new level
for (int i = 0 ; i < row ; i++)
{
for (int j = 0 ; j < col ; j++)
{
b [i] [j] = a [i] [j];
}
}
//sets the original grid to the new level
for (int i = 0 ; i < row ; i++)
{
for (int j = 0 ; j < col ; j++)
{
ogb [i] [j] = c [i] [j];
}
}
redraw ();
where = -1;
storemove ();
}
public void storemove ()
{
//stores current position of grid into undo array
where++;
for (int i = 0 ; i < row ; i++)
{
for (int j = 0 ; j < col ; j++)
{
undo [where] [i] [j] = b [i] [j];
}
}
undoy [where] = cury;
undox [where] = curx;
}
public boolean checkwin ()
{
//win condition checks if each of the yellow dot spaces contain boulders. If there are no storage locations then it returns true. else returns false
int count = 0;
for (int i = 0 ; i < row ; i++)
{
for (int j = 0 ; j < col ; j++)
{
if (b [i] [j] == 4)
count++;
}
}
//if win is true
if (count == 0)
return true;
else
return false;
}
//Checks if win condition is met, if it is then proceed to win screen
public void proceedtowin ()
{
if (checkwin ())
{
cdLayout.show (p_card, "4");
b [0] [0] = 4;
}
}
//RESET METHOD
public void reset ()
{
if (level == 1)
newLevel (b1, ogb1, 0);
else if (level == 2)
newLevel (b2, ogb2, 1);
else if (level == 3)
newLevel (b3, ogb3, 2);
else if (level == 4)
newLevel (b4, ogb4, 3);
else if (level == 5)
newLevel (b5, ogb5, 4);
else if (level == 6)
newLevel (b6, ogb6, 5);
score = 0;
moves.setText ("Moves: " + score);
cdLayout.show (p_card, "3");
time = 0;
}
//UNDO METHOD
public void undo ()
{
//reduce score and where variables by 1 because of the undo
score--;
//if score does not become negative, also means that there was a move made
if (score > -1)
{
where--;
//copies previous move into the current array
for (int i = 0 ; i < row ; i++)
{
for (int j = 0 ; j < col ; j++)
{
b [i] [j] = undo [where] [i] [j];
}
}
curx = undox [where];
cury = undoy [where];
redraw ();
moves.setText ("Moves: " + score);
}
else
{
score++;
ins.setText ("Make a move to undo.");
}
}
//LEVEL SELECT METHOD
public void lvlselect (int lvl)
{
//Sets the level to the screen based on which level was selected
if (lvl == 1)
{
level = 1;
newLevel (b1, ogb1, 0);
score = 0;
time = 0;
moves.setText ("Moves: " + score);
curlevel.setText ("Level: " + level);
cdLayout.show (p_card, "3");
}
else if (lvl == 2)
{
level = 2;
newLevel (b2, ogb2, 1);
score = 0;
time = 0;
moves.setText ("Moves: " + score);
curlevel.setText ("Level: " + level);
cdLayout.show (p_card, "3");
}
else if (lvl == 3)
{
level = 3;
newLevel (b3, ogb3, 2);
score = 0;
time = 0;
moves.setText ("Moves: " + score);
curlevel.setText ("Level: " + level);
cdLayout.show (p_card, "3");
}
else if (lvl == 4)
{
level = 4;
newLevel (b4, ogb4, 3);
score = 0;
time = 0;
moves.setText ("Moves: " + score);
curlevel.setText ("Level: " + level);
cdLayout.show (p_card, "3");
}
else if (lvl == 5)
{
level = 5;
newLevel (b5, ogb5, 4);
score = 0;
time = 0;
moves.setText ("Moves: " + score);
curlevel.setText ("Level: " + level);
cdLayout.show (p_card, "3");
}
else if (lvl == 6)
{
level = 6;
newLevel (b6, ogb6, 5);
score = 0;
time = 0;
moves.setText ("Moves: " + score);
curlevel.setText ("Level: " + level);
cdLayout.show (p_card, "3");
}
}
//MOVEMENT METHODS
public void moveup ()
{ //move character up
if (b [curx - 1] [cury] != 1)
{
//box and box
if (b [curx - 1] [cury] == 5 && b [curx - 2] [cury] == 5)
{
ins.setText ("Boulder beside a Boulder.\nTry something else!");
}
//box and blank
else if (b [curx - 1] [cury] == 5 && b [curx - 2] [cury] != 1)
{
b [curx - 1] [cury] = ogb [curx - 1] [cury];
b [curx - 2] [cury] = 5;
curx--;
ins.setText ("Use arrow keys.\nor Use W, A, S, D");
}
//box and wall
else if (b [curx - 1] [cury] == 5 && b [curx - 2] [cury] == 1)