-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathGameSparker.java
1726 lines (1618 loc) · 66.6 KB
/
GameSparker.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
import fallk.logmaster.HLogger;
import java.applet.Applet;
import java.awt.*;
import java.io.*;
import java.net.URI;
import java.util.Date;
import java.util.Enumeration;
import java.util.Objects;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
/**
* GameSparker brings everything together.
*
* @author Kaffeinated, Omar Waly
*/
public class GameSparker extends Applet implements Runnable {
/**
*
*/
private static final long serialVersionUID = -34048182014310663L;
private static final String[] carModels = {
"2000tornados", "formula7", "canyenaro", "lescrab", "nimi", "maxrevenge", "leadoxide", "koolkat", "drifter",
"policecops", "mustang", "king", "audir8", "masheen", "radicalone", "drmonster"
};
private static final String[] trackModels = {
"road", "froad", "twister2", "twister1", "turn", "offroad", "bumproad", "offturn", "nroad", "nturn",
"roblend", "noblend", "rnblend", "roadend", "offroadend", "hpground", "ramp30", "cramp35", "dramp15",
"dhilo15", "slide10", "takeoff", "sramp22", "offbump", "offramp", "sofframp", "halfpipe", "spikes", "rail",
"thewall", "checkpoint", "fixpoint", "offcheckpoint", "sideoff", "bsideoff", "uprise", "riseroad", "sroad",
"soffroad"
};
private static final String[] extraModels = {};
/**
* false to disable splash
*/
private static final boolean splashScreenState = true;
private static final String stageDir = "stages/";
/**
* Set directory for temporary creation of cookies (directory is deleted after writing is complete)
*/
private static final String cookieDirTemp = "data/cookies/";
/**
* Set location for the cookie.radq
*/
private static final String cookieDirZip = "data/cookies.radq";
private String stageError = "";
private Graphics2D rd;
private Graphics sg;
private Image offImage;
private Thread gamer;
private final Control[] u;
private int mouses;
private int xm;
private int ym;
private boolean lostfcs;
private boolean exwist;
private int nob;
private int notb;
private int view;
/* variables for screen shake */
private int shaka = 0;
private int apx = 0;
private int apy = 0;
/**
* <a href="http://www.expandinghead.net/keycode.html">http://www.expandinghead.net/keycode.html</a>
*/
@Override
public boolean keyDown(Event event, int i) {
if (!exwist) {
if (i == 1004)
u[0].up = true;
if (i == 1005)
u[0].down = true;
if (i == 1007)
u[0].right = true;
if (i == 1006)
u[0].left = true;
if (i == 32)
u[0].handb = true;
if (i == 120 || i == 88)
u[0].lookback = -1;
if (i == 122 || i == 90)
u[0].lookback = 1;
if (i == 10 || i == 80 || i == 112 || i == 27)
u[0].enter = true;
if (i == 77 || i == 109)
Control.mutem = !Control.mutem;
if (i == 78 || i == 110)
Control.mutes = !Control.mutes;
if (i == 97 || i == 65)
u[0].arrace = !u[0].arrace;
if (i == 118 || i == 86) {
view++;
if (view == 3)
view = 0;
}
}
return false;
}
@Override
public void stop() {
if (exwist && gamer != null) {
System.gc();
gamer.stop();
gamer = null;
}
exwist = true;
}
@Override
public boolean lostFocus(Event event, Object obj) {
if (!exwist && !lostfcs) {
lostfcs = true;
mouses = 0;
u[0].falseo();
setCursor(new Cursor(0));
}
return false;
}
@Override
public boolean gotFocus(Event event, Object obj) {
if (!exwist && lostfcs)
lostfcs = false;
return false;
}
private void savecookie(String filename, String num) {
try {
/**
* since I want full control over the filenames, we'll create a normal file in the temporary file directory
*/
try {
File cookieTempLocation = new File(cookieDirTemp);
if (!cookieTempLocation.exists()) {
cookieTempLocation.mkdirs();
}
File[] cookieFile = {
new File(cookieDirTemp + filename + ".dat")
};
if (!cookieFile[0].exists()) {
cookieFile[0].createNewFile();
}
FileWriter fw = new FileWriter(cookieFile[0].getPath());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(num + '\n');
bw.close();
File cookieZip = new File(cookieDirZip);
if (!cookieZip.exists()) {
cookieZip.createNewFile();
}
addFile(cookieZip, cookieFile, "");
cookieFile[0].delete();
cookieTempLocation.delete();
HLogger.info("Successfully saved game (" + filename + ")");
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static String fromStream(InputStream in) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder out = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
out.append(line);
}
return out.toString();
}
/**
* attempts to read a cookie
*
* @param string name to match
* @return value
*/
private int readcookie(String string) {
try {
ZipFile zipFile = new ZipFile(cookieDirZip);
Enumeration<? extends ZipEntry> entries = zipFile.entries();
String fromEntry = " ";
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (entry.getName().contains(string)) {
InputStream stream = zipFile.getInputStream(entry);
fromEntry = fromStream(stream);
}
}
zipFile.close();
HLogger.info("Successfully read cookie " + string + " with value " + Integer.parseInt(fromEntry));
return Integer.parseInt(fromEntry);
} catch (IOException ioexception) {
// HLogger.error(ioexception.toString());
HLogger.error(string + ".dat probably doesn't exist");
return -1;
} catch (NumberFormatException nfe) {
return -1;
}
}
private void cropit(final Graphics2D graphics2d, final int i, final int i_98_) {
if (i != 0 || i_98_ != 0) {
graphics2d.setComposite(AlphaComposite.getInstance(3, 1.0F));
graphics2d.setColor(new Color(0, 0, 0));
}
if (i != 0) {
if (i < 0) {
graphics2d.fillRect(apx + i, apy - (int) (25.0F), Math.abs(i), (int) (400.0F));
} else {
graphics2d.fillRect(apx + (int) (670.0F), apy - (int) (25.0F), i, (int) (400.0F));
}
}
if (i_98_ != 0) {
if (i_98_ < 0) {
graphics2d.fillRect(apx - (int) (25.0F), apy + i_98_, (int) (720.0F), Math.abs(i_98_));
} else {
graphics2d.fillRect(apx - (int) (25.0F), apy + (int) (450.0F), (int) (720.0F), i_98_);
}
}
}
@Override
public void paint(Graphics g) {
final Graphics2D graphics2d = (Graphics2D) g;
int i = 0;
int i_97_ = 0;
if (shaka > 10) {
i = (int) ((shaka * 2 * Math.random() - shaka));
i_97_ = (int) ((shaka * 2 * Math.random() - shaka));
shaka--;
}
apx = (int) (getWidth() / 2 - 335.0F);
apy = (int) (getHeight() / 2 - 200.0F);
graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics2d.drawImage(offImage, apx + i, apy + i_97_, this);
cropit(graphics2d, i, i_97_);
}
public GameSparker() {
u = new Control[7];
mouses = 0;
xm = 0;
ym = 0;
lostfcs = false;
exwist = true;
nob = 0;
notb = 0;
view = 0;
}
/**
* @param input name of model you want id of
* @return Position on model in array. If you spelled it wrong or if it doesn't eist, it returns -1, so you have that to look forward to.
* @author Kaffeinated
*/
private int getModel(String input) {
String[][] allModels = new String[][]{
carModels, trackModels, extraModels
}; /// need to have all the model arrays here
int modelId = 0;
for (int i = 0; i < allModels.length; i++) {
for (int j = 0; j < allModels[i].length; j++) {
if (Objects.equals(input, allModels[i][j])) {
int addWhat = 0;
if (i == 1) {
addWhat = carModels.length;
}
if (i == 2) {
addWhat = carModels.length + trackModels.length;
}
modelId = j + addWhat;
//HLogger.info("Found model " + modelId + " matching string \"" + input + "\"");
return modelId;
}
}
}
HLogger.warn("No results for getModel | check you're speling and grammer");
return -1;
}
/**
* Loads all models
*
* @param conto conto instance
* @param trackers trackers instance
* @param xtgraphics xtgraphics instance
* @author Kaffeinated, Omar Waly
*/
private void loadbase(final ContO conto[], Trackers trackers, xtGraphics xtgraphics) {
xtgraphics.dnload += 6;
try {
ZipInputStream zipinputstream;
final File file = new File(new StringBuilder().append("").append("data/models.radq").toString());
zipinputstream = new ZipInputStream(new FileInputStream(file));
ZipEntry zipentry = zipinputstream.getNextEntry();
for (; zipentry != null; zipentry = zipinputstream.getNextEntry()) {
int modelId = -1;
final int carCount = carModels.length;
final int trackCount = trackModels.length;
// final int extraCount = extraModels.length;
for (int car = 0; car < carModels.length; car++)
if (zipentry.getName().startsWith(carModels[car]))
modelId = car;
for (int track = 0; track < trackModels.length; track++)
if (zipentry.getName().startsWith(trackModels[track]))
modelId = track + carCount;
for (int extra = 0; extra < extraModels.length; extra++)
if (zipentry.getName().startsWith(extraModels[extra]))
modelId = extra + trackCount + carCount;
int entireSize = (int) zipentry.getSize();
final byte[] modelData = new byte[entireSize];
int unknown1 = 0;
int unknown2;
for (; entireSize > 0; entireSize -= unknown2) {
unknown2 = zipinputstream.read(modelData, unknown1, entireSize);
unknown1 += unknown2;
}
conto[modelId] = new ContO(modelData, trackers);
xtgraphics.dnload++;
}
/*
* be sure to add your added arrays here
*/
HLogger.info("Contos loaded: " + (carModels.length + trackModels.length + extraModels.length));
zipinputstream.close();
} catch (IOException e) {
HLogger.error("Error Reading Models: " + e);
e.printStackTrace();
}
System.gc();
}
@Override
public void update(Graphics g) {
paint(g);
}
/**
* <a href="http://www.expandinghead.net/keycode.html">http://www.expandinghead.net/keycode.html</a>
*/
@Override
public boolean keyUp(Event event, int i) {
if (!exwist) {
if (i == 1004)
u[0].up = false;
if (i == 1005)
u[0].down = false;
if (i == 1007)
u[0].right = false;
if (i == 1006)
u[0].left = false;
if (i == 32)
u[0].handb = false;
if (i == 120 || i == 88 || i == 122 || i == 90)
u[0].lookback = 0;
}
return false;
}
@Override
public void start() {
if (gamer == null)
gamer = new Thread(this);
if (gamer.getState() == Thread.State.NEW)
gamer.start();
}
@Override
public boolean mouseDown(Event event, int i, int j) {
if (!exwist && mouses == 0) {
xm = i;
ym = j;
mouses = 1;
}
return false;
}
/**
* Loads stage elements
*
* @param aconto conto instance
* @param aconto1 conto instance specifically for cars
* @param trackers trackers instance
* @param checkpoints checkpoints instance
* @param xtgraphics xtgraphics instance
* @param amadness madness instance
* @param record record instance
* @author Kaffeinated, Omar Waly
*/
private void loadstage(ContO aconto[], ContO aconto1[], Trackers trackers, CheckPoints checkpoints,
xtGraphics xtgraphics, Madness amadness[], Record record) {
trackers.nt = 0;
nob = 7;
notb = 0;
checkpoints.n = 0;
checkpoints.nsp = 0;
checkpoints.fn = 0;
checkpoints.haltall = false;
checkpoints.wasted = 0;
checkpoints.catchfin = 0;
Medium.lightson = false;
Medium.lton = false;
Medium.ground = 250;
view = 0;
final int wall_id = getModel("thewall");
int r_wall = 0;
int l_wall = 100;
int t_wall = 0;
int b_wall = 100;
try (BufferedReader bufferedreader = new BufferedReader(new FileReader(new File(stageDir + checkpoints.stage + ".txt")))) {
for (String line; (line = bufferedreader.readLine()) != null; ) {
line = line.trim();
if (line.startsWith("mountains"))
Medium.mgen = Utility.getint("mountains", line, 0);
if (line.startsWith("snap"))
Medium.setSnap(Utility.getint("snap", line, 0), Utility.getint("snap", line, 1), Utility.getint("snap", line, 2));
if (line.startsWith("sky")) {
Medium.setSky(Utility.getint("sky", line, 0), Utility.getint("sky", line, 1), Utility.getint("sky", line, 2));
xtgraphics.snap(checkpoints.stage);
}
if (line.startsWith("ground"))
Medium.setGround(Utility.getint("ground", line, 0), Utility.getint("ground", line, 1), Utility.getint("ground", line, 2));
if (line.startsWith("polys"))
Medium.setPolys(Utility.getint("polys", line, 0), Utility.getint("polys", line, 1), Utility.getint("polys", line, 2));
if (line.startsWith("fog"))
Medium.setFade(Utility.getint("fog", line, 0), Utility.getint("fog", line, 1), Utility.getint("fog", line, 2));
if (line.startsWith("density"))
Medium.fogd = Utility.getint("density", line, 0);
if (line.startsWith("texture")) {
Medium.setTexture(Utility.getint("texture", line, 0), Utility.getint("texture", line, 1), Utility.getint("texture", line, 2),
Utility.getint("texture", line, 3));
}
if (line.startsWith("clouds")) {
Medium.setClouds(Utility.getint("clouds", line, 0), Utility.getint("clouds", line, 1), Utility.getint("clouds", line, 2),
Utility.getint("clouds", line, 3), Utility.getint("clouds", line, 4));
}
if (line.startsWith("fadefrom")) {
Medium.fadeFrom(Utility.getint("fadefrom", line, 0));
Medium.origfade = Medium.fade[0];
}
if (line.startsWith("lightson"))
Medium.lightson = true;
if (line.startsWith("set")) {
int k1 = Utility.getint("set", line, 0);
k1 += 6;
aconto[nob] = new ContO(aconto1[k1], Utility.getint("set", line, 1), Medium.ground - aconto1[k1].grat,
Utility.getint("set", line, 2), Utility.getint("set", line, 3));
if (line.contains(")p")) {
checkpoints.x[checkpoints.n] = Utility.getint("set", line, 1);
checkpoints.z[checkpoints.n] = Utility.getint("set", line, 2);
checkpoints.y[checkpoints.n] = 0;
checkpoints.typ[checkpoints.n] = 0;
if (line.contains(")pt"))
checkpoints.typ[checkpoints.n] = -1;
if (line.contains(")pr"))
checkpoints.typ[checkpoints.n] = -2;
if (line.contains(")po"))
checkpoints.typ[checkpoints.n] = -3;
if (line.contains(")ph"))
checkpoints.typ[checkpoints.n] = -4;
checkpoints.n++;
notb = nob + 1;
}
nob++;
}
if (line.startsWith("fltset")) {
int i2 = Utility.getint("fltset", line, 0);
i2 += 6;
aconto[nob] = new ContO(aconto1[i2], Utility.getint("fltset", line, 1), Utility.getint("fltset", line, 3),
Utility.getint("fltset", line, 2), Utility.getint("fltset", line, 4));
if (line.contains(")p")) {
checkpoints.x[checkpoints.n] = Utility.getint("fltset", line, 1);
checkpoints.z[checkpoints.n] = Utility.getint("fltset", line, 2);
checkpoints.y[checkpoints.n] = Utility.getint("fltset", line, 3);
checkpoints.typ[checkpoints.n] = 0;
if (line.contains(")pt")) {
checkpoints.typ[checkpoints.n] = -1;
}
if (line.contains(")pr")) {
checkpoints.typ[checkpoints.n] = -2;
}
if (line.contains(")po")) {
checkpoints.typ[checkpoints.n] = -3;
}
if (line.contains(")ph")) {
checkpoints.typ[checkpoints.n] = -4;
}
checkpoints.n++;
notb = nob + 1;
}
nob++;
}
if (line.startsWith("chk")) {
int l1 = Utility.getint("chk", line, 0);
l1 += 6;
aconto[nob] = new ContO(aconto1[l1], Utility.getint("chk", line, 1), Medium.ground - aconto1[l1].grat,
Utility.getint("chk", line, 2), Utility.getint("chk", line, 3));
checkpoints.x[checkpoints.n] = Utility.getint("chk", line, 1);
checkpoints.z[checkpoints.n] = Utility.getint("chk", line, 2);
checkpoints.y[checkpoints.n] = Medium.ground - aconto1[l1].grat;
if (Utility.getint("chk", line, 3) == 0)
checkpoints.typ[checkpoints.n] = 1;
else
checkpoints.typ[checkpoints.n] = 2;
checkpoints.pcs = checkpoints.n;
checkpoints.n++;
aconto[nob].checkpoint = checkpoints.nsp + 1;
checkpoints.nsp++;
nob++;
notb = nob;
}
if (line.startsWith("fltchk")) {
int l1 = Utility.getint("fltchk", line, 0);
l1 += 6;
aconto[nob] = new ContO(aconto1[l1], Utility.getint("fltchk", line, 1), Utility.getint("fltchk", line, 3),
Utility.getint("fltchk", line, 2), Utility.getint("fltchk", line, 4));
checkpoints.x[checkpoints.n] = Utility.getint("fltchk", line, 1);
checkpoints.z[checkpoints.n] = Utility.getint("fltchk", line, 2);
checkpoints.y[checkpoints.n] = Utility.getint("fltchk", line, 3);
if (Utility.getint("fltchk", line, 4) == 0)
checkpoints.typ[checkpoints.n] = 1;
else
checkpoints.typ[checkpoints.n] = 2;
checkpoints.pcs = checkpoints.n;
checkpoints.n++;
aconto[nob].checkpoint = checkpoints.nsp + 1;
checkpoints.nsp++;
nob++;
notb = nob;
}
if (line.startsWith("fix")) {
int i2 = Utility.getint("fix", line, 0);
i2 += 6;
aconto[nob] = new ContO(aconto1[i2], Utility.getint("fix", line, 1), Utility.getint("fix", line, 3),
Utility.getint("fix", line, 2), Utility.getint("fix", line, 4));
checkpoints.fx[checkpoints.fn] = Utility.getint("fix", line, 1);
checkpoints.fz[checkpoints.fn] = Utility.getint("fix", line, 2);
checkpoints.fy[checkpoints.fn] = Utility.getint("fix", line, 3);
aconto[nob].elec = true;
if (Utility.getint("fix", line, 4) != 0) {
checkpoints.roted[checkpoints.fn] = true;
aconto[nob].roted = true;
} else {
checkpoints.roted[checkpoints.fn] = false;
}
checkpoints.special[checkpoints.fn] = line.contains(")s");
checkpoints.fn++;
nob++;
notb = nob;
}
if (line.startsWith("nlaps"))
checkpoints.nlaps = Utility.getint("nlaps", line, 0);
if (line.startsWith("name"))
checkpoints.name = Utility.getstring("name", line, 0).replace('|', ',');
if (line.startsWith("maxr")) {
int j2 = Utility.getint("maxr", line, 0);
int j3 = Utility.getint("maxr", line, 1);
r_wall = j3;
int j4 = Utility.getint("maxr", line, 2);
for (int j5 = 0; j5 < j2; j5++) {
aconto[nob] = new ContO(aconto1[wall_id], j3, Medium.ground - aconto1[wall_id].grat,
j5 * 4800 + j4, 0);
nob++;
}
trackers.y[trackers.nt] = -5000;
trackers.rady[trackers.nt] = 7100;
trackers.x[trackers.nt] = j3 + 500;
trackers.radx[trackers.nt] = 600;
trackers.z[trackers.nt] = ((j2 * 4800) / 2 + j4) - 2400;
trackers.radz[trackers.nt] = (j2 * 4800) / 2;
trackers.xy[trackers.nt] = 90;
trackers.zy[trackers.nt] = 0;
trackers.dam[trackers.nt] = 1;
trackers.nt++;
}
if (line.startsWith("maxl")) {
int k2 = Utility.getint("maxl", line, 0);
int k3 = Utility.getint("maxl", line, 1);
l_wall = k3;
int k4 = Utility.getint("maxl", line, 2);
for (int k5 = 0; k5 < k2; k5++) {
aconto[nob] = new ContO(aconto1[wall_id], k3, Medium.ground - aconto1[wall_id].grat,
k5 * 4800 + k4, 0);
nob++;
}
trackers.y[trackers.nt] = -5000;
trackers.rady[trackers.nt] = 7100;
trackers.x[trackers.nt] = k3 - 500;
trackers.radx[trackers.nt] = 600;
trackers.z[trackers.nt] = ((k2 * 4800) / 2 + k4) - 2400;
trackers.radz[trackers.nt] = (k2 * 4800) / 2;
trackers.xy[trackers.nt] = -90;
trackers.zy[trackers.nt] = 0;
trackers.dam[trackers.nt] = 1;
trackers.nt++;
}
if (line.startsWith("maxt")) {
int l2 = Utility.getint("maxt", line, 0);
int l3 = Utility.getint("maxt", line, 1);
t_wall = l3;
int l4 = Utility.getint("maxt", line, 2);
for (int l5 = 0; l5 < l2; l5++) {
aconto[nob] = new ContO(aconto1[wall_id], l5 * 4800 + l4, Medium.ground - aconto1[wall_id].grat,
l3, 90);
nob++;
}
trackers.y[trackers.nt] = -5000;
trackers.rady[trackers.nt] = 7100;
trackers.z[trackers.nt] = l3 + 500;
trackers.radz[trackers.nt] = 600;
trackers.x[trackers.nt] = ((l2 * 4800) / 2 + l4) - 2400;
trackers.radx[trackers.nt] = (l2 * 4800) / 2;
trackers.zy[trackers.nt] = 90;
trackers.xy[trackers.nt] = 0;
trackers.dam[trackers.nt] = 1;
trackers.nt++;
}
if (line.startsWith("maxb")) {
int i3 = Utility.getint("maxb", line, 0);
int i4 = Utility.getint("maxb", line, 1);
b_wall = i4;
int i5 = Utility.getint("maxb", line, 2);
for (int i6 = 0; i6 < i3; i6++) {
aconto[nob] = new ContO(aconto1[wall_id], i6 * 4800 + i5, Medium.ground - aconto1[wall_id].grat,
i4, 90);
nob++;
}
trackers.y[trackers.nt] = -5000;
trackers.rady[trackers.nt] = 7100;
trackers.z[trackers.nt] = i4 - 500;
trackers.radz[trackers.nt] = 600;
trackers.x[trackers.nt] = ((i3 * 4800) / 2 + i5) - 2400;
trackers.radx[trackers.nt] = (i3 * 4800) / 2;
trackers.zy[trackers.nt] = -90;
trackers.xy[trackers.nt] = 0;
trackers.dam[trackers.nt] = 1;
trackers.nt++;
}
}
Medium.newpolys(l_wall, r_wall - l_wall, b_wall, t_wall - b_wall, trackers, notb);
Medium.newmountains(l_wall, r_wall, b_wall, t_wall);
Medium.newclouds(l_wall, r_wall, b_wall, t_wall);
Medium.newstars();
} catch (IOException e) {
String exceptStr = e.toString();
final int maxChar = 30;
int maxLength = (exceptStr.length() < maxChar) ? exceptStr.length() : maxChar;
stageError = e.toString().substring(0, maxLength) + "...";
xtgraphics.fase = 3;
HLogger.error("Error loading stage " + checkpoints.stage);
e.printStackTrace();
}
if (checkpoints.stage == 16)
Medium.lightn = 0;
else
Medium.lightn = -1;
Medium.nochekflk = checkpoints.stage != 1;
if (xtgraphics.fase == 2) {
Medium.trx = 0L;
Medium.trz = 0L;
if (trackers.nt >= 4) {
int i1 = 4;
do {
Medium.trx += trackers.x[trackers.nt - i1];
Medium.trz += trackers.z[trackers.nt - i1];
} while (--i1 > 0);
}
Medium.trx = Medium.trx / 4L;
Medium.trz = Medium.trz / 4L;
Medium.ptr = 0;
Medium.ptcnt = -10;
Medium.hit = 45000;
Medium.fallen = 0;
Medium.nrnd = 0;
Medium.trk = true;
xtgraphics.fase = 1;
mouses = 0;
}
int j1 = 0;
do
u[j1].reset(checkpoints, xtgraphics.sc[j1]);
while (++j1 < 7);
xtgraphics.resetstat(checkpoints.stage);
j1 = 0;
do {
aconto[j1] = new ContO(aconto1[xtgraphics.sc[j1]], xtgraphics.xstart[j1],
250 - aconto1[xtgraphics.sc[j1]].grat, xtgraphics.zstart[j1], 0);
amadness[j1].reseto(xtgraphics.sc[j1], aconto[j1], checkpoints);
} while (++j1 < 7);
record.reset(aconto);
System.gc();
}
/**
* motion
*
* @param amadness madness
* @param shakeAmt shake sensitivity
* 1 normal
* 20 maximum
* @param maxAmt maximum displacement of the screen while shaking
*/
private void initMoto(Madness amadness[], int shakeAmt, int maxAmt) {
if (amadness[0].shakedam > 0) {
shaka = amadness[0].shakedam / (20 / shakeAmt);
amadness[0].shakedam = 0;
if (shaka > maxAmt) {
shaka = maxAmt;
}
shaka--;
}
}
@Override
public void run() {
rd.setColor(new Color(0, 0, 0));
rd.fillRect(0, 0, 670, 400);
repaint();
/*
* start an example timer
*/
Utility.startTimer();
Trackers trackers = new Trackers();
CheckPoints checkpoints = new CheckPoints();
xtGraphics xtgraphics = new xtGraphics(rd, this);
xtgraphics.loaddata();
Record record = new Record();
ContO aconto[] = new ContO[carModels.length + trackModels.length + extraModels.length]; // be sure all your arrays get in here
loadbase(aconto, trackers, xtgraphics);
ContO aconto1[] = new ContO[3000];
Madness amadness[] = new Madness[7];
int l = 0;
do {
amadness[l] = new Madness(record, xtgraphics, l);
u[l] = new Control();
} while (++l < 7);
float f = 35F;
int i1 = 80;
/*
* stop an example timer
*/
Utility.stopTimer();
/**
* this bit in here reads cookies and set values
*/
l = readcookie("unlocked");
if (l >= 1 && l <= 17) {
/*
* Note: that is an L
*/
xtgraphics.unlocked = l;
if (xtgraphics.unlocked != 17)
checkpoints.stage = xtgraphics.unlocked;
else
checkpoints.stage = (int) (Math.random() * 17D) + 1;
xtgraphics.opselect = 0;
}
l = readcookie("usercar");
if (l >= 0 && l <= 15)
xtgraphics.sc[0] = l;
l = readcookie("gameprfact");
if (l != -1) {
f = l;
i1 = 1;
}
xtgraphics.stoploading();
System.gc();
Date date = new Date();
int i = 15;
int j = 530;
long l3 = date.getTime();
float f1 = 30F;
boolean flag1 = false;
int j1 = 0;
int k1 = 0;
int i2 = 0;
int j2 = 0;
int k2 = 0;
boolean flag2 = false;
exwist = false;
do {
Date date1 = new Date();
long l4 = date1.getTime();
if (xtgraphics.fase == 111) {
if (mouses == 1)
i2 = 800;
if (i2 < 800) {
xtgraphics.clicknow();
i2++;
} else {
i2 = 0;
xtgraphics.fase = 9;
mouses = 0;
lostfcs = false;
}
}
if (xtgraphics.fase == 9)
if (i2 < 71 && splashScreenState) {
xtgraphics.rad(i2, 1);
catchlink(0);
if (mouses == 2)
mouses = 0;
if (mouses == 1)
mouses = 2;
i2++;
} else {
i2 = 0;
xtgraphics.fase = 10;
mouses = 0;
u[0].falseo();
}
if (xtgraphics.fase == -9)
if (i2 < 2) {
rd.setColor(new Color(0, 0, 0));
rd.fillRect(0, 0, 670, 400);
i2++;
} else {
xtgraphics.inishcarselect();
i2 = 0;
xtgraphics.fase = 7;
mouses = 0;
}
if (xtgraphics.fase == 8) {
xtgraphics.credits(u[0]);
if (xtgraphics.flipo == 102) {
rd.drawImage(xtgraphics.credsnap(offImage), 0, 0, null);
}
xtgraphics.ctachm(xm, ym, mouses, u[0]);
if (xtgraphics.flipo <= 100)
catchlink(0);
if (mouses == 2)
mouses = 0;
if (mouses == 1)
mouses = 2;
}
if (xtgraphics.fase == 10) {
xtgraphics.maini(u[0]);
xtgraphics.ctachm(xm, ym, mouses, u[0]);
if (mouses == 2)
mouses = 0;
if (mouses == 1)
mouses = 2;
}
if (xtgraphics.fase == 11) {
xtgraphics.inst(u[0]);
xtgraphics.ctachm(xm, ym, mouses, u[0]);
if (mouses == 2)
mouses = 0;
if (mouses == 1)
mouses = 2;
}
if(xtgraphics.fase == -205) {
if (checkpoints.stage == xtgraphics.unlocked && xtgraphics.winner && xtgraphics.unlocked != 17)
savecookie("unlocked", "" + xtgraphics.unlocked);
savecookie("gameprfact", "" + (int) f);
savecookie("usercar", "" + xtgraphics.sc[0]);
xtgraphics.fase = -5;
}
if (xtgraphics.fase == -5) {
xtgraphics.finish(checkpoints, aconto, u[0]);
xtgraphics.ctachm(xm, ym, mouses, u[0]);
if (checkpoints.stage == 17 && xtgraphics.winner)
catchlink(1);
if (mouses == 2)
mouses = 0;
if (mouses == 1)
mouses = 2;
}
if (xtgraphics.fase == 7) {
xtgraphics.carselect(u[0], aconto, amadness[0]);
xtgraphics.ctachm(xm, ym, mouses, u[0]);
if (mouses == 2)
mouses = 0;
if (mouses == 1)
mouses = 2;
}
if (xtgraphics.fase == 6) {
xtgraphics.musicomp(checkpoints.stage, u[0]);
xtgraphics.ctachm(xm, ym, mouses, u[0]);
if (mouses == 2)
mouses = 0;
if (mouses == 1)
mouses = 2;
}
if (xtgraphics.fase == 205) {
savecookie("usercar", "" + xtgraphics.sc[0]);
for (int x = 0; x < 7; x++) {
amadness[x].stat = new Stat(xtgraphics.sc[x]);
}
xtgraphics.fase = 5;
}
if (xtgraphics.fase == 5) {
xtgraphics.loadmusic(checkpoints.stage, i1);
}
if (xtgraphics.fase == 4) {
xtgraphics.cantgo(u[0]);
xtgraphics.ctachm(xm, ym, mouses, u[0]);
if (mouses == 2)
mouses = 0;
if (mouses == 1)
mouses = 2;
}
if (xtgraphics.fase == 3) {
xtgraphics.loadingfailed(checkpoints, u[0], stageError);
xtgraphics.ctachm(xm, ym, mouses, u[0]);
if (mouses == 2)
mouses = 0;
if (mouses == 1)
mouses = 2;
}
if (xtgraphics.fase == 2) {
xtgraphics.loadingstage(checkpoints.stage);
loadstage(aconto1, aconto, trackers, checkpoints, xtgraphics, amadness, record);
u[0].falseo();
}
if (xtgraphics.fase == 1) {
rd.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
xtgraphics.trackbg(false);
Medium.aroundTrack(checkpoints);
int i3 = 0;
int ai[] = new int[200];
for (int k5 = 7; k5 < notb; k5++)
if (aconto1[k5].dist != 0) {
ai[i3] = k5;
i3++;
} else {
aconto1[k5].d(rd);
}
int ai5[] = new int[i3];
for (int j7 = 0; j7 < i3; j7++)
ai5[j7] = 0;
for (int k7 = 0; k7 < i3; k7++) {
for (int i11 = k7 + 1; i11 < i3; i11++)
if (aconto1[ai[k7]].dist != aconto1[ai[i11]].dist) {
if (aconto1[ai[k7]].dist < aconto1[ai[i11]].dist)
ai5[k7]++;
else
ai5[i11]++;
} else if (i11 > k7)
ai5[k7]++;