-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrex_quest.ino
886 lines (793 loc) · 50.6 KB
/
trex_quest.ino
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
//imports the SPI library (needed to communicate with Gamebuino's screen)
#include <SPI.h>
//imports the Gamebuino library
#include <Gamebuino.h>
//creates a Gamebuino object named gb
// TREX QUEST II (v1.5) 08/06/2017 By AWOT
// todo :
// multiply tanks (increase by levels)
// multiply cars (fun)
// better tank sprite
// level 2 : forced scrolling ?
// obstacles + forced scrolling ? out of screen = dead
Gamebuino gb;
int CarY;
int x = 10;
int y = 10;
int pomx = 30; // apple x position
int tankx = 0; // tank x pos
int tanky = 20; // tank y pos
int pomy = 30; // appel Y pos
int direc = 0;
int carstate = 0;
int statefire = 0;
int tankstate = 0;
int explode = 0; // is tank exploded ?
int puissance = 11; // power bar status
int barredevie = 42; // life bar status
int score = 0;
int chilyrand = 0; // randomized 1/10 to have a chily instead of apple
int activateRay = 0; // used to know if chily is eaten to activate the ray
int RayOrFireHitBox = 16; // used for the width of hitbox of the fire =16 or Ray= 88
int leveln = 0; // level counter
int SpeedUp = 1; // speed multiplicateur
int Scrolling = 0; // scrolling of the buildings
int Scrolling2 = 0; // scrolling of 1rst plan
const byte CAR1[] PROGMEM = {24, 10, 0x7, 0xE0, 0x0, 0x7C, 0x3F, 0x80, 0x8C, 0x30, 0x40, 0xEC, 0x3D, 0x40, 0xEB, 0xFD, 0x40, 0x87, 0x30, 0x40, 0xFF, 0xFF, 0xC0, 0xFF, 0xFF, 0xC0, 0xEF, 0xFD, 0xC0, 0x7F, 0xFF, 0x80,};
const byte CAR1X[] PROGMEM = {16, 7, 0x1F, 0x0, 0x71, 0xF0, 0x91, 0x88, 0x9F, 0x88, 0xFF, 0xF8, 0xDF, 0xD8, 0x70, 0x70,};
const byte CAR2[] PROGMEM = {24, 12, 0x3, 0xE0, 0x0, 0x2, 0x30, 0x0, 0x7E, 0x3F, 0x0, 0x82, 0x31, 0x80, 0xBE, 0x30, 0x80, 0xBE, 0x30, 0x80, 0xBE, 0xD1, 0x80, 0x80, 0xE0, 0x80, 0x80, 0x0, 0x80, 0xB8, 0x1D, 0x80, 0xEF, 0xF7, 0x80, 0x7F, 0xFF, 0x0,};
const byte CAR2X[] PROGMEM = {16, 8, 0xE, 0x0, 0x7B, 0xC0, 0x8B, 0x20, 0x8B, 0x20, 0xFF, 0x20, 0xFF, 0xE0, 0xDF, 0x60, 0x71, 0xC0,};
const byte CAR3[] PROGMEM = {24, 12, 0x1, 0x80, 0x0, 0x6, 0xC0, 0x0, 0x79, 0x3F, 0x80, 0xE9, 0xB7, 0xC0, 0xE8, 0x33, 0xC0, 0xE6, 0xD7, 0xC0, 0xEE, 0xEF, 0xC0, 0x91, 0x9, 0x40, 0xF9, 0x2F, 0xC0, 0xFD, 0xF, 0xC0, 0xEF, 0xFD, 0xC0, 0x7F, 0xFF, 0x80,};
const byte CAR3X[] PROGMEM = {16, 8, 0xC, 0x0, 0x6B, 0xC0, 0xEA, 0xE0, 0xD6, 0xE0, 0xD5, 0xE0, 0xE9, 0xE0, 0xF9, 0xE0, 0x7F, 0xC0,};
const byte CAR4[] PROGMEM = {24, 14, 0x0, 0x30, 0x0, 0xFF, 0xE8, 0x0, 0x80, 0x3C, 0x0, 0x80, 0x3F, 0x0, 0x80, 0x2D, 0x80, 0xD1, 0x7C, 0x80, 0x80, 0xC, 0x80, 0x89, 0xB4, 0x80, 0x9D, 0xB8, 0x80, 0x88, 0x1, 0x80, 0xB0, 0x1C, 0x80, 0xA8, 0x15, 0x80, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0x0,};
const byte CAR4X[] PROGMEM = {16, 9, 0x3, 0x0, 0xFE, 0x80, 0x83, 0xC0, 0xA2, 0xA0, 0xF5, 0xA0, 0xA1, 0xE0, 0xF1, 0xE0, 0xDF, 0x60, 0x71, 0xC0,};
const byte CAR5[] PROGMEM = {24, 10, 0xF, 0xC0, 0x0, 0x30, 0x7E, 0x0, 0x48, 0x61, 0x80, 0xA8, 0x60, 0x40, 0xA5, 0xA0, 0x40, 0x8D, 0xC3, 0x40, 0x80, 0x0, 0x40, 0xB8, 0xE, 0xC0, 0xEF, 0xFB, 0xC0, 0x7F, 0xFF, 0x80,};
const byte CAR5X[] PROGMEM = {16, 6, 0x3C, 0x0, 0x67, 0xC0, 0xDE, 0x20, 0xFC, 0xE0, 0xBF, 0xA0, 0xE0, 0xE0,};
const byte CAR6[] PROGMEM = {2, 2, 0, 0, 0};
const byte CarExplode[] PROGMEM = {24, 14, B00010000, B00000100, B00000000, B00110010, B01011000, B00000000, B00011011, B00111111, B00000000, B01001110, B01111010, B00000000, B00010110, B11010001, B10000000, B01011011, B00110011, B00000000, B01001111, B11100111, B00000000, B01101100, B11011111, B00000000, B00111111, B01111010, B00000000, B00101111, B11101010, B10000000, B10001011, B10010101, B00000000, B11100101, B00100111, B10000000, B00110101, B11101110, B00000000, B00000110, B01101000, B00000000,};
const byte cloud1[] PROGMEM = {88, 27, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7F, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xE0, 0x70, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0xC, 0x1F, 0xFF, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF9, 0xC6, 0x0, 0x3, 0x38, 0x0, 0xC3, 0xFF, 0xE0, 0x7F, 0x70, 0xE, 0x6C, 0x0, 0x1, 0xE0, 0x0, 0x6E, 0x0, 0x31, 0xE0, 0xC0, 0x4, 0x18, 0x0, 0x0, 0x80, 0x7F, 0xD8, 0x0, 0x17, 0x0, 0x0, 0xF, 0x80, 0xF, 0xF0, 0x3, 0x80, 0x70, 0x0, 0x8, 0x0, 0x0, 0x38, 0x3F, 0x30, 0x3F, 0x6, 0x0, 0x1C, 0x1F, 0xF0, 0x0, 0xF8, 0x60, 0x1, 0xC0, 0x0, 0x9C, 0x0, 0x6, 0x70, 0xE, 0x7, 0xE, 0xC0, 0x0, 0x60, 0x0, 0x70, 0x0, 0x0, 0xC0, 0x3, 0x1C, 0x3, 0x80, 0x0, 0x20, 0x0, 0x0, 0x0, 0x1, 0x80, 0x0, 0xB0, 0x1, 0x30, 0x0, 0x1F, 0xC0, 0x0, 0x0, 0x7F, 0x0, 0x0, 0x60, 0xE0, 0xCC,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0x7C, 0x7C, 0x7C, 0x7C, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0xE0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x80, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x10, 0x2, 0x0, 0x0, 0x80, 0x0, 0x40, 0x0, 0x4, 0x0, 0x8, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x7F, 0xFF, 0xFF, 0xE3, 0xFF,};
const byte GAMEOVER[] PROGMEM = {64, 36,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111110,
B10000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000010,
B10000000, B01110000, B10000000, B00111000, B00001110, B01000101, B11011100, B00000010,
B10000000, B10000001, B01000101, B00100000, B00010001, B01000101, B00010010, B00000010,
B10001000, B10000011, B11001010, B10110000, B00010101, B01000101, B10011110, B00100010,
B10011100, B10011010, B00101000, B10100000, B00010101, B00101001, B00010100, B01110010,
B10001000, B10001010, B00101000, B10100000, B00010001, B00111001, B00010010, B00100010,
B10000000, B11111010, B00101000, B10111000, B00001110, B00010001, B11010010, B00000010,
B10000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000010,
B10000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000010,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111110,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000001, B11100000, B00000000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000110, B00011000, B00000000, B00000000, B00000000, B00000000,
B01110110, B01110110, B11000101, B00001000, B00000000, B00000000, B00000001, B11111100,
B01010101, B01100100, B10001001, B11000100, B00000000, B00000000, B00000001, B11111100,
B01110110, B01000010, B01001001, B00100100, B00000000, B00000000, B00000001, B11111110,
B01000101, B01110110, B11000101, B11001000, B00000000, B00000000, B00000001, B11111110,
B00000000, B00000000, B00000110, B00011000, B00000000, B00000000, B00001101, B11111110,
B00000000, B00000000, B00000001, B11100000, B00000000, B00000000, B00001101, B11111110,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00001101, B11111110,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000011, B10001111, B11111110,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000001, B11001111, B11101010,
B00000000, B00000000, B00000000, B00000000, B00111000, B00001100, B11001111, B11110110,
B00000000, B00000000, B00000000, B00000000, B00110000, B00000111, B11111111, B11101010,
B00000000, B00000000, B00000000, B00000000, B00111100, B11111111, B11111111, B11111110,
B00000000, B00000000, B00000000, B00000000, B00011111, B11111111, B11111111, B11111110,
B00000000, B00000000, B00000000, B00000000, B00011111, B11111111, B11111111, B11111110,
B00000000, B00000000, B00000000, B00000000, B00011111, B11111111, B11111111, B11111100,
B00000000, B00000000, B00000000, B00000000, B00001111, B11111111, B11111111, B11111100,
B00000000, B00000000, B00000000, B00000000, B00000111, B11111111, B11111111, B11111000,
B00100100, B01001011, B10011001, B10010110, B00000111, B11111111, B11111100, B00000000,
B01010101, B01010101, B00001010, B01010010, B00001111, B10001111, B11111001, B11110000,
B01010011, B10001001, B00001101, B10010010, B00011111, B11111000, B01111011, B11111100,
B00000000, B00000000, B00000000, B00000000, B01111001, B11111111, B11110000, B00000000,
};
const byte logo2[] PROGMEM = {88, 43,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B11000000, B00000000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00001111, B11111111, B11111110, B00000001, B10001000, B00000010, B00000000, B00000000, B00000000,
B00000000, B00000011, B11111111, B11111111, B11111111, B00000011, B00011000, B11000110, B10000000, B00000000, B00000000,
B00000000, B00011111, B11111111, B11111111, B11111111, B10000110, B00110001, B10001101, B10000000, B00011100, B00000000,
B00000000, B01111111, B11111111, B11111111, B11111111, B10001110, B01100011, B10011011, B00000000, B01100000, B00000000,
B00000000, B11111111, B11111111, B11111111, B11111111, B10001100, B01000111, B00100000, B00110001, B11000000, B00000000,
B00000000, B11111111, B11111111, B11111111, B11111111, B10011000, B00111111, B00000000, B11110110, B00000011, B10000000,
B00000001, B11111100, B00011111, B11111111, B11111111, B10011000, B01111111, B11111111, B11100100, B00001111, B00000000,
B00000001, B11111100, B00011111, B11111111, B11111111, B10000000, B11110011, B11111111, B11000000, B01111110, B01100000,
B00000001, B11111100, B00011111, B11111111, B11111111, B10000011, B11100111, B11000000, B00000111, B11111001, B11110000,
B00000001, B11111100, B00011111, B11111111, B11111111, B00001111, B11001111, B11111111, B11111111, B11111111, B11110000,
B00000001, B11111111, B11111111, B11111111, B11111111, B00111100, B00111111, B11111111, B10000000, B00000000, B00000000,
B00000001, B11111111, B11111111, B11111111, B11111111, B00111111, B11111111, B00000011, B11111111, B11111111, B11110000,
B00000001, B11111111, B11111111, B11111111, B11111110, B00111011, B11111111, B11111111, B11111111, B11111111, B11110000,
B00000001, B11111111, B11111111, B11111111, B11111000, B01100010, B00000111, B11111111, B11111111, B11111111, B11110000,
B00000001, B11111111, B11111111, B11111111, B00000000, B11111111, B11111111, B11111100, B00000000, B00000000, B00000000,
B00000001, B11111111, B11111111, B11111100, B00011111, B10001111, B11111111, B11111111, B11111111, B11111111, B11110000,
B00000001, B11111111, B11111111, B11110000, B01111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000,
B00000001, B11111111, B11111111, B11110001, B11111100, B11111111, B11000000, B00000000, B00000000, B00000000, B00000000,
B00000001, B11111111, B11111111, B11100111, B10000111, B10000000, B00000000, B00000000, B00000000, B00000000, B00000000,
B00000001, B11111111, B11111111, B11100111, B11111111, B10000000, B00000000, B00000000, B00000000, B00000000, B00000000,
B00000011, B11111111, B11111111, B11100001, B11111110, B11111110, B00000000, B00011111, B11111111, B11111111, B11110000,
B00000011, B11111111, B11111111, B11100000, B00111111, B01111111, B11111111, B11111111, B11111111, B11111111, B11110000,
B00000111, B11111111, B11111111, B11111000, B00011111, B10011111, B11111111, B11111111, B11111111, B11111111, B11110000,
B00000111, B11111111, B11111111, B11111111, B11101111, B11111110, B00000000, B01111000, B00000000, B00000000, B01110000,
B00001111, B11111111, B11111111, B11111111, B11100111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000,
B00011111, B11111111, B11111111, B11111111, B11100011, B11110011, B11111111, B11111111, B11111111, B11111111, B11110000,
B00111111, B11111111, B11111111, B11111100, B00000011, B11111001, B11110001, B11100000, B01001111, B11111011, B10010000,
B11111111, B11111111, B11111111, B10000000, B00000001, B10111110, B01111110, B00111111, B00111000, B01111111, B11000000,
B11111111, B11111111, B11111111, B00000000, B00000001, B10011110, B01111111, B11111111, B00000110, B01111110, B11100000,
B11111111, B11111111, B11111111, B00000000, B00000001, B11011111, B00001111, B11110111, B11100011, B10001111, B11100000,
B11111111, B11111111, B11111111, B00000000, B00000001, B11001111, B10001011, B00111011, B11111100, B11000110, B01100000,
B11111111, B11111111, B11111111, B00000000, B00000000, B01100011, B11000001, B10011000, B11111111, B00000111, B00100000,
B11111111, B11111111, B11111111, B00000000, B00000000, B00110000, B11110000, B11000110, B00000111, B11000011, B00000000,
B11111111, B11111111, B11111111, B11111111, B10000000, B00011011, B00111000, B01100011, B00000000, B11100000, B00000000,
B11111111, B11111111, B11111111, B11111111, B11000000, B00001001, B10001100, B00100001, B11000000, B00000000, B00000000,
B11111111, B11111111, B11111111, B11111111, B11000000, B00001000, B10000110, B00010000, B01000000, B00000000, B00000000,
B11111111, B11111111, B11111111, B11111110, B11000000, B00001100, B11000010, B00000000, B00000000, B00000000, B00000000,
B11111111, B11111111, B11111111, B11100110, B11000000, B00000100, B01100011, B00000000, B00000000, B00000000, B00000000,
B11111111, B11111111, B11100000, B01100110, B00000000, B00000100, B00011000, B00000000, B00000000, B00000000, B00000000,
B11111111, B11111111, B11000000, B00110000, B00000000, B00000110, B00001100, B00000000, B00000000, B00000000, B00000000,
B11111111, B11111111, B11000000, B00000000, B00000000, B00000000, B00000110, B00000000, B00000000, B00000000, B00000000,
B11111111, B11111111, B11000000, B00000000, B00000000, B00000000, B00000010, B00000000, B00000000, B00000000, B00000000,
};
const byte logo[] PROGMEM = {64, 36,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111110,
B10000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000010,
B10111111, B00111110, B00111011, B00110000, B11100011, B01100111, B00111101, B11111010,
B10111111, B00110011, B01101101, B11100001, B11110011, B01101101, B10110001, B11111010,
B10001100, B00110011, B01101100, B11000011, B00011011, B01101101, B10110000, B01100010,
B10001101, B10111110, B01111000, B11000011, B00011011, B01101111, B00011100, B01100010,
B10001101, B10110110, B01100001, B11100011, B00011011, B01101100, B01101100, B01100010,
B10001100, B00110111, B00111011, B00110001, B11110001, B11000111, B00111100, B01100010,
B10000000, B00000000, B00000000, B00000000, B11111000, B00000000, B00000000, B00000010,
B10000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000010,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111110,
B00000000, B00000000, B00000001, B11100000, B00000000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000110, B00011000, B00000000, B00000000, B00000000, B00000000,
B01110110, B01110110, B11000100, B11001000, B00011111, B11111110, B00000000, B00000000,
B01010101, B01100100, B10001001, B00100100, B01111111, B11110011, B11000000, B00000000,
B01110110, B01000010, B01001001, B11100100, B01111111, B11110011, B11000000, B00000000,
B01000101, B01110110, B11000101, B00101000, B01111111, B11111111, B11000000, B00000000,
B00000000, B00000000, B00000110, B00011000, B01111111, B11111111, B11000000, B00000000,
B00000000, B00000000, B00000001, B11100000, B01111111, B11111111, B11000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B01111111, B11111111, B11000000, B00000000,
B00110000, B11111111, B00000001, B10000000, B01111111, B11111111, B11000000, B00000000,
B00110011, B11111111, B11111111, B10000000, B00000000, B11111111, B11000000, B00000000,
B00110011, B11111111, B11111111, B10000000, B00000111, B11111111, B11000000, B00000000,
B00110011, B11111110, B11000001, B10000000, B00000111, B11111111, B11000000, B00000000,
B00110011, B11111110, B11000001, B10000000, B00000000, B00011111, B11110000, B00000110,
B00111111, B11111111, B11111100, B00000000, B00000000, B00011111, B11111000, B00000110,
B00111111, B11111111, B11111100, B00000000, B00000001, B11111111, B11111111, B00011110,
B01111111, B11111111, B11111111, B10000000, B00000001, B11111111, B11111111, B00011110,
B01111111, B11111111, B11111111, B11100000, B00000001, B11111111, B11111111, B00011110,
B01111111, B11111111, B11111111, B11100000, B00000001, B00001111, B11111111, B11111110,
B01110011, B11100111, B11001111, B11100000, B00000000, B00001111, B11111111, B11111110,
B01110011, B11100111, B11001111, B11101001, B00010010, B11101111, B00110011, B01001110,
B01111111, B11111111, B11111111, B10010101, B01010101, B01000111, B10101101, B01101110,
B00111111, B11111111, B11111110, B00010100, B11100010, B01000011, B10010011, B01101000,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000011, B11111111, B11111000,
};
const byte ray[] PROGMEM = {88, 16,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00010000, B00000000, B00000000, B00000100, B10000000,
B00000000, B00000000, B00000000, B00000000, B00001000, B01000010, B00000001, B00110011, B00100110, B01100010, B01010000,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00010010, B00011001, B10000001, B10000011, B01110000,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000,
B00000000, B00000000, B00000000, B00000000, B00100000, B01000000, B00001000, B00001111, B10001111, B10000000, B01110000,
B11110011, B11001111, B11101111, B10011111, B00011000, B00000001, B00000000, B10011000, B00111000, B11000111, B00110000,
B00000000, B00000000, B00000000, B00000010, B00000000, B00000100, B00000100, B00000001, B00010000, B00111001, B11110000,
B00000000, B00000000, B00000000, B00000000, B00000000, B00010000, B01010000, B00000001, B00000000, B00000000, B01110000,
B00000000, B00000000, B00000000, B00000000, B00000001, B00000000, B00000000, B00111001, B11001100, B11011000, B00110000,
B10011111, B11101111, B10111111, B10001111, B11110000, B00010000, B00000100, B11100000, B01110110, B01001111, B11110000,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000010, B01000000, B00111100, B00011011, B11110001, B11110000,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11110000,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B01001000, B00011110, B00000111, B00001111, B11110000,
B00000000, B00000000, B00000000, B00000000, B00000000, B01001000, B00000000, B11110000, B00111100, B01111011, B10100000,
B00000000, B00000000, B00000010, B00000000, B00010000, B00000000, B01000011, B10000100, B01100000, B11000010, B01100000,
B00000000, B00000000, B00000000, B00000001, B00000000, B00010000, B00000100, B00000001, B11000000, B00000000, B01000000,
};
const byte trex1[] PROGMEM = {16, 16,
B00000000, B11111110,
B00000001, B10111111,
B00000001, B11111111,
B00000001, B11111111,
B00000001, B11110000,
B00000001, B11111100,
B10000011, B11100000,
B10000111, B11100000,
B11001111, B11111000,
B11111111, B11001000,
B11111111, B11000000,
B11111111, B11000000,
B01111111, B10000000,
B00111111, B10000000,
B00010001, B00000000,
B00011001, B10000000,
};
const byte trex1g[] PROGMEM = {16, 16,
B01111111, B00000000,
B11111101, B10000000,
B11111111, B10000000,
B11111111, B10000000,
B00001111, B10000000,
B00111111, B10000000,
B00000111, B11000001,
B00000111, B11100001,
B00011111, B11110011,
B00010011, B11111111,
B00000011, B11111111,
B00000011, B11111111,
B00000001, B11111110,
B00000001, B11111100,
B00000001, B00010000,
B00000011, B00110000,
};
const byte trex2[] PROGMEM = {16, 16,
B00000000, B11111110,
B00000001, B10111111,
B00000001, B11111111,
B00000001, B11111111,
B00000001, B11110100,
B00000001, B11111100,
B01000011, B11100000,
B01000111, B11100000,
B11001111, B11110000,
B11111111, B11010000,
B11111111, B11000000,
B11111111, B11000000,
B01111111, B11000000,
B00111111, B11000000,
B00001000, B01000000,
B00001100, B01100000,
};
const byte trex2g[] PROGMEM = {16, 16,
B01111111, B00000000,
B11111101, B10000000,
B11111111, B10000000,
B11111111, B10000000,
B00101111, B10000000,
B00111111, B10000000,
B00000111, B11000010,
B00000111, B11100010,
B00001111, B11110011,
B00001011, B11111111,
B00000011, B11111111,
B00000011, B11111111,
B00000011, B11111110,
B00000011, B11111100,
B00000010, B00010000,
B00000110, B00110000,
};
const byte pom[] PROGMEM = {16, 9,
B00000100, B00000000,
B00001000, B00000000,
B01111111, B00000000,
B11111110, B10000000,
B11111110, B10000000,
B11111111, B10000000,
B11111111, B10000000,
B01111111, B00000000,
B00111110, B00000000,
};
const byte fire0[] PROGMEM = {16, 16,
B00000000, B00000000,
B00000000, B00000000,
B01000000, B00000000,
B01001000, B00000000,
B10000000, B00000000,
B11010100, B00000000,
B10100000, B00000000,
B00010000, B00000000,
B11000100, B00000000,
B01000000, B00000000,
B00100000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
};
const byte fire0g[] PROGMEM = {16, 16,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000010,
B00000000, B00010010,
B00000000, B00000001,
B00000000, B00101011,
B00000000, B00000101,
B00000000, B00001000,
B00000000, B00100011,
B00000000, B00000010,
B00000000, B00000100,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
};
const byte fire1[] PROGMEM = {16, 16,
B00000000, B00000000,
B00000000, B01100000,
B00000110, B00100000,
B00000010, B01000000,
B11110111, B10000000,
B11001110, B00000100,
B11001000, B11111000,
B01100101, B11000000,
B01111011, B00000000,
B00110010, B11001000,
B00010011, B00000000,
B00000101, B11000000,
B00000000, B10010000,
B00000000, B10000000,
B00000000, B00000000,
B00000000, B00000000,
};
const byte fire1g[] PROGMEM = {16, 16,
B00000000, B00000000,
B00000110, B00000000,
B00000100, B01100000,
B00000010, B01000000,
B00000001, B11101111,
B00100000, B01110011,
B00011111, B00010011,
B00000011, B10100110,
B00000000, B11011110,
B00010011, B01001100,
B00000000, B11001000,
B00000011, B10100000,
B00001001, B00000000,
B00000001, B00000000,
B00000000, B00000000,
B00000000, B00000000,
};
const byte fire2[] PROGMEM = {16, 16,
B00000000, B00000000,
B00000000, B01100000,
B00000110, B00101010,
B00011010, B01011110,
B11110111, B10110100,
B11011111, B11101100,
B11001100, B00011110,
B01101111, B11100000,
B01111111, B00111100,
B00110010, B10000110,
B00011111, B10110000,
B00101110, B00111100,
B00000101, B11111000,
B00000001, B10100100,
B00010001, B01000000,
B00000000, B00000000,
};
const byte fire2g[] PROGMEM = {16, 16,
B00000000, B00000000,
B00000110, B00000000,
B01010100, B01100000,
B01111010, B01011000,
B00101101, B11101111,
B00110111, B11111011,
B01111000, B00110011,
B00000111, B11110110,
B00111100, B11111110,
B01100001, B01001100,
B00001101, B11111000,
B00111100, B01110100,
B00011111, B10100000,
B00100101, B10000000,
B00000010, B10001000,
B00000000, B00000000,
};
const byte tank1[] PROGMEM = {16, 16,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B10000111, B11000010,
B01001111, B11111110,
B01101111, B10100010,
B00111111, B11111000,
B01111111, B11111110,
B11111111, B11111111,
B11111111, B11111111,
B01110111, B01110110,
B00111111, B11111100,
};
const byte tank2[] PROGMEM = {16, 16,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00000000, B00000000,
B00100111, B11000010,
B00101111, B11111110,
B00101111, B10100010,
B00111111, B11111000,
B01111111, B11111110,
B11111111, B11111111,
B11101110, B11101111,
B01111111, B11111110,
B00111111, B11111100,
};
const byte tank3[] PROGMEM = {16, 16,
B00000000, B00000000,
B00000000, B00000000,
B01100110, B00000000,
B00100100, B01000010,
B00110100, B01100110,
B00010101, B10100100,
B00010101, B01101100,
B00010111, B11011010,
B11010111, B11111110,
B01100101, B10100010,
B00110101, B10111110,
B01111001, B10001010,
B10101111, B10111011,
B11101110, B10101111,
B01111011, B10111110,
B00111111, B11111100,
};
const byte tank4[] PROGMEM = {16, 16,
B00000000, B00000000,
B00000000, B00000000,
B00100000, B00000010,
B00000010, B00000000,
B00000000, B00100000,
B00000100, B10000000,
B00000000, B00000100,
B00000000, B00000010,
B00100000, B00101010,
B00000100, B10000000,
B00000001, B00010110,
B00010100, B00000000,
B00001000, B10010010,
B01010110, B00000001,
B00001001, B00101010,
B00000000, B00000100,
};
const byte minipom[] PROGMEM = {8, 8,
B00001000,
B00011100,
B00100110,
B01000011,
B01001001,
B10011001,
B01011010,
B00110100,
};
const byte chily[] PROGMEM = {16, 9,
B00010000, B00000000,
B00001000, B00000000,
B00011100, B00000000,
B00111110, B00000000,
B00111010, B00000000,
B00111100, B00000000,
B00011100, B00000000,
B00011000, B00000000,
B00110000, B00000000,
};
const byte heart[] PROGMEM = {8, 8,
B00000000,
B01110110,
B11011111,
B10111111,
B11011111,
B01101110,
B00111100,
B00011000,
};
// array containing the different sprites
#define NUM_SPRITESCARS 6
const byte* cars[NUM_SPRITESCARS] = {
CAR1, //0
CAR2, //1
CAR3, //2
CAR4, //3
CAR5, //4
CAR6, //5 empty sprite
};
#define NUM_SPRITES 4
const byte* sprites[NUM_SPRITES] = {
trex1, //0
trex1g, //1
trex2, //2
trex2g, //3
};
#define NUM_TANK 4
const byte* tank[NUM_TANK] = {
tank1, //0
tank2, //1
tank3, //2
tank4, //3
};
#define NUM_FIRE 3
const byte* fire[NUM_FIRE] = {
fire0, //0
fire1, //1
fire2, //2
};
#define NUM_FIRE 3
const byte* fireg[NUM_FIRE] = {
fire0g, //0
fire1g, //1
fire2g, //2
};
// the setup routine runs once when Gamebuino starts up
void setup() {
initGame();
// initialize the Gamebuino object
gb.begin();
mainMenu();
//display the main menu:
}
void initGame()
{
barredevie = 42;
tankx = 0; // re init tank
tanky = random(10, LCDHEIGHT - 10); //re init tank y
score = 0; // re init score
puissance = 11; //re init puissance bar
leveln = 1;
SpeedUp = 1;
CarY = random(35, LCDHEIGHT - 8); //re init CAR y
}
void mainMenu() {
gb.titleScreen(F(""), logo);
gb.pickRandomSeed();
gb.battery.show = false;
}
void NextLevel()
{
leveln++;
SpeedUp++;
loop();
}
// the loop routine runs over and over again forever
void loop() {
//updates the gamebuino (the display, the sound, the auto backlight... everything)
//returns true when it's time to render a new frame (20 times/second)
if (gb.update()) {
gb.display.drawBitmap(Scrolling, 8, horizon1);
gb.display.drawBitmap(Scrolling + LCDWIDTH, 8, horizon1);
gb.display.drawBitmap(Scrolling - LCDWIDTH, 8, horizon1);
gb.display.drawBitmap(Scrolling2, 30, horizon3);
gb.display.drawBitmap(Scrolling2 + LCDWIDTH, 30, horizon3);
gb.display.drawBitmap(Scrolling2 - LCDWIDTH, 30, horizon3);
gb.display.setColor(WHITE, WHITE);
gb.display.fillRect(Scrolling2 + LCDWIDTH + 5+1,CarY+1, 24, 9);
gb.display.setColor(BLACK, BLACK);
gb.display.drawBitmap(Scrolling2 + LCDWIDTH + 5, CarY, cars[carstate]);
//gb.display.drawBitmap(Scrolling2 + LCDWIDTH, CarY, CAR1X);
//gb.display.drawBitmap(Scrolling2 - LCDWIDTH, CarY, CAR1X);
// re init scrolling
if (Scrolling2 == - 2 * LCDWIDTH) {
Scrolling2 = 0;
CarY = random(32, LCDHEIGHT - 4); //re init CAR y
pomx = random(10, LCDWIDTH);
pomy = random(20, LCDHEIGHT - 15);
carstate = random(0, 4);
}
if (Scrolling == - 2 * LCDWIDTH) {
Scrolling = 0; //a ajuster pour éviter le saut
}
if (barredevie <= 59) {
// exit game
if (gb.buttons.pressed(BTN_C)) {
setup();
}
//draw the field and barre de vie puissance
gb.display.drawLine(0, 18, LCDWIDTH , 18);
//barre de puissance
gb.display.drawRect(LCDWIDTH - 30, 2, 20, 3);
gb.display.drawLine(LCDWIDTH - 30, 3, LCDWIDTH - puissance , 3);
// barre de vie
gb.display.drawRect(LCDWIDTH - 60, 2, 20, 3);
gb.display.drawLine(LCDWIDTH - 60, 3, LCDWIDTH - barredevie , 3);
//emplacement du score
gb.display.cursorX = 1;
gb.display.cursorY = 0;
gb.display.println(score);
//POM OR CHILLY
if (chilyrand == 5) {
gb.display.drawBitmap(pomx, pomy, chily);
}
else {
gb.display.drawBitmap(pomx, pomy, pom);
}
//TANK
gb.display.drawBitmap(tankx, tanky, tank[tankstate], NOROT, FLIPH);
gb.display.drawBitmap(LCDWIDTH - 69, 0, heart);
gb.display.drawBitmap(LCDWIDTH - 39, 0, minipom);
//TREX
gb.display.setColor(WHITE, WHITE);
if (direc == 0 or direc == 2) { // TREX RIGHT SIDE -
gb.display.fillRect(x + 7, y, 5, 3);
}
if (direc == 1 or direc == 3) { // TREX LEFT SIDE -
gb.display.fillRect(x + 3, y, 5, 3);
}
gb.display.setColor(BLACK, BLACK);
gb.display.drawBitmap(x, y, sprites[direc]);
explode = 0;
// ------- Controls ----------------------------------------------
if (gb.buttons.repeat(BTN_RIGHT, 1)) {
Scrolling--;
Scrolling2 = Scrolling2 - 2;
tankx--;
pomx--;
if (x < LCDWIDTH - 25) {
x = x + 1;
}
direc = direc + 2;
if ( direc > 2) {
direc = 0;
}
}
if (gb.buttons.repeat(BTN_LEFT, 1)) {
Scrolling++;
Scrolling2 = Scrolling2 + 2;
tankx++;
pomx++;
if (x > 0) {
x = x - 1;
}
direc = direc + 2;
if ( direc > 3) {
direc = 1;
}
}
if (gb.buttons.repeat(BTN_DOWN, 1)) {
if (y < LCDHEIGHT - 8) {
y = y + 1;
}
}
if (gb.buttons.repeat(BTN_UP, 1)) {
if (y > 6) {
y = y - 1;
}
}
if (gb.buttons.repeat(BTN_A, 1)) {
if (puissance < 30) {
puissance++; // ----------------------------->>>>fait baisser la barre de puissance
puissance++;
puissance--;
}
// ------------------------------------------------------------------
// draw right fire ----------
if (direc == 0 or direc == 2) {
if (puissance < 29) {
if (activateRay == 0) { // if chily was NOT eaten
gb.display.drawBitmap(x + 17, y, fire[statefire]); // le feu n'est possible que si la barre de puissance n'est pas vide
}
if (activateRay == 1) { // if chily was eaten
gb.display.drawBitmap(x + 10, y - 4, ray, NOROT, FLIPH); // le feu n'est possible que si la barre de puissance n'est pas vide
}
}
statefire = statefire + 1;
if ( statefire > 2) {
statefire = 0;
}
}
// draw left fire ----------
if (direc == 1 or direc == 3) {
if (puissance < 30) {
if (activateRay == 1) { // if chily was eaten
gb.display.drawBitmap(x - 81 , y - 4, ray);
}
if (activateRay == 0) { // if chily was NOT eaten
gb.display.drawBitmap(x - 17, y, fire[statefire], NOROT, FLIPH); // le feu n'est possible que si la barre de puissance n'est pas vide
}
}
statefire = statefire + 1;
if ( statefire > 2) {
statefire = 0;
}
}
}
// when trex touch apple -----------------------------------
if (gb.collideBitmapBitmap(x, y, sprites[direc], pomx, pomy, pom)) {
score = score + 5;
pomx = random(10, LCDWIDTH);
pomy = random(20, LCDHEIGHT - 15);
if (chilyrand == 5) {
activateRay = 1; // if chily is eaten activate ray
RayOrFireHitBox = 88; // and change the hitbox of the fire
puissance = 11; // power bar to the max with the chily
}
if (chilyrand != 5) {
activateRay = 0; // if apple is eaten dont activate ray
RayOrFireHitBox = 16; // and the hitbox of the fire
}
chilyrand = random(1, 10); // 1 chance / 10 to have a chily
if (puissance > 11) {
puissance = puissance - 4; //augmente la barre de puissance
if (puissance < 11) {
puissance = 11; // pour ne pas dépasser la barre de puissance
}
}
}
// when trex touch tank with HITBOX -----------------------------------
if (gb.collideRectRect(x, y, 16, 2, tankx, CarY, 8, 2)) {
if (barredevie < 60) {
barredevie++; //fait baisser la barre de vie
}
}
// when trex touch CAR with HITBOX -----------------------------------
if (gb.collideRectRect(x, y, 16, 2, tankx, tanky, 16, 2)) {
if (barredevie < 60) {
barredevie++; //fait baisser la barre de vie
}
}
// when trex burn tank -----------------------------------
if (gb.buttons.repeat(BTN_A, 1)) {
if (puissance < 30) { // le tank n'explose que si le boutton est appuillé ET que le feu crache, (donc que la barre de feu pas vide)
if (gb.collideRectRect(x + 17, y + 16, RayOrFireHitBox, 2, tankx, tanky + 16, 16, 2)) { // si les HITBOX tank et fire se touchent
if (direc == 0 || direc == 2) { // Si t rex vers la droite
explode = 1;
tankstate = 3;
tankx = -16;
tanky = random(10, LCDHEIGHT - 10);
score = score + 10;
}
}
if (gb.collideRectRect(x - 17, y + 16, RayOrFireHitBox, 2, tankx, tanky + 16, 16, 2)) { // si TREX est vers la gauche et que les HITBOX tank et fire se touchent
if (direc == 1 || direc == 3) { // Si t rex vers la gauche
explode = 1;
tankstate = 3;
tankx = -16;
tanky = random(10, LCDHEIGHT - 10);
score = score + 10;
}
}
}
}
if (explode < 1) {
if (tankx > 0 - 16) {
tankx = tankx - (1 * SpeedUp);
}
if (tankx < 0 - 16) {
tankx = LCDWIDTH + 16;
tanky = random(10, LCDHEIGHT - 10); //re init tank y
}
tankstate = tankstate + 1;
if (tankstate > 1) {
tankstate = 0;
}
}
}
// --- when TREX WALKS on CARS
if (gb.collideBitmapBitmap(x, y, sprites[direc], Scrolling2 + LCDWIDTH + 5, CarY, cars[carstate])) {
gb.display.drawBitmap(Scrolling2 + LCDWIDTH + 5, CarY, CarExplode); // car explosion
CarY=LCDHEIGHT+20;
}
// GAME OVER
if (barredevie > 59) {
gb.display.clear();
// gb.display.print(F("GAME OVER!"), 20);
// ESSAYER DE FAIRE AFFICHER LE SCORE ET GAME OVER ------------------------------ TBD
gb.display.print(F("Score: "));
gb.display.print(score);
gb.display.drawBitmap(10, 10, GAMEOVER);
if (gb.buttons.repeat(BTN_B, 1)) {
initGame();
}
}
// Next level
if (score >= 100 * leveln) {
gb.display.clear();
gb.display.print(F("LEVEL: "));
gb.display.print(leveln);
gb.display.drawBitmap(0, 5, logo2);
if (gb.buttons.repeat(BTN_B, 1)) {
NextLevel();
}
}
} // void gb.update
} // void loop