-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTankForceOne.ino
More file actions
645 lines (598 loc) · 26.3 KB
/
Copy pathTankForceOne.ino
File metadata and controls
645 lines (598 loc) · 26.3 KB
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
#include <Tinyfont.h>
#include <ArduboyTones.h>
#include <Arduboy2.h>
Arduboy2 arduboy;
ArduboyTones sound(arduboy.audio.enabled);
Tinyfont tinyfont = Tinyfont(arduboy.sBuffer, Arduboy2::width(), Arduboy2::height());
const unsigned char skull[] PROGMEM = {
0x00, 0x00, 0x04, 0x04, 0xe8, 0x10, 0xe8, 0xe8, 0x08, 0xe8, 0xe8, 0x10, 0xe8, 0x06, 0x00, 0x00,
0x00, 0x00, 0x60, 0x20, 0x10, 0x0d, 0x12, 0x1e, 0x12, 0x1e, 0x12, 0x0d, 0x10, 0x20, 0x60, 0x00,
};
const unsigned char explosion[] PROGMEM = {
0x87, 0x78, 0x00, 0x8f, 0x70, 0x03, 0xff, 0xff, 0xff, 0xff, 0x01, 0xfc, 0x02, 0x31, 0xec, 0x03,
0x03, 0xc4, 0x38, 0x83, 0x78, 0x03, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x84, 0x71, 0x0e, 0xe0, 0x1f,
0x00, 0xff, 0x00, 0x7f, 0x80, 0x7f, 0xff, 0xff, 0xff, 0x1f, 0x40, 0xbf, 0x00, 0xff, 0x00, 0x00,
0x0f, 0x10, 0xe6, 0x09, 0xf0, 0x07, 0xff, 0xff, 0xff, 0xfe, 0xf8, 0x03, 0xbc, 0x40, 0x1f, 0xe0,
0x00, 0xff, 0x00, 0xfe, 0x01, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x01, 0xfc, 0x07, 0xf0, 0x0f, 0x00,
0xf0, 0x0f, 0xe0, 0x1f, 0x60, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0x00, 0x7f, 0x80, 0x00,
0x01, 0x0e, 0xf8, 0x03, 0xfc, 0x01, 0xcf, 0xff, 0xff, 0xff, 0xfe, 0xe0, 0x0f, 0xf0, 0x07, 0xf8,
0x80, 0x60, 0x1f, 0xc0, 0x3f, 0x80, 0xe7, 0xff, 0xff, 0xff, 0x83, 0x3c, 0x42, 0x99, 0x64, 0x83,
};
const unsigned char gameOver[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
0xa0, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0xa0, 0x9f, 0x90, 0x90, 0x90, 0x90,
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x50, 0x30, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x01, 0xff, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0x80, 0x40, 0x3f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char start[] PROGMEM = {
0x07, 0x05, 0x7d, 0x41, 0x7d, 0x05, 0x07, 0x00, 0x7f, 0x41, 0x75, 0x15, 0x75, 0x41, 0x7f, 0x00,
0x7f, 0x41, 0x7d, 0x41, 0x5f, 0x41, 0x7f, 0x00, 0x7f, 0x41, 0x63, 0x49, 0x7f, 0x00, 0x00, 0x00,
0x7f, 0x41, 0x75, 0x1d, 0x07, 0x00, 0x7f, 0x41, 0x5d, 0x41, 0x7f, 0x00, 0x7f, 0x41, 0x75, 0x11,
0x77, 0x44, 0x7c, 0x00, 0x7f, 0x41, 0x5d, 0x55, 0x77, 0x00, 0x7f, 0x41, 0x55, 0x5d, 0x77, 0x00,
0x00, 0x00, 0x7f, 0x41, 0x5d, 0x41, 0x7f, 0x00, 0x7f, 0x41, 0x7d, 0x41, 0x5f, 0x41, 0x7f, 0x00,
0x7f, 0x41, 0x55, 0x5d, 0x77, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x22, 0x77, 0x22, 0x88, 0xdc,
0x88, 0x22, 0x77, 0x22, 0x88, 0xdc, 0x88, 0x22, 0x77, 0x22, 0x88, 0xdc, 0x88, 0x22, 0x77, 0x22,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x22, 0x77, 0x22, 0x88, 0xdd,
0x88, 0x22, 0x77, 0x22, 0x88, 0xdd, 0x88, 0x22, 0x77, 0x22, 0x88, 0xdd, 0x88, 0x22, 0x77, 0x22,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x26, 0x21, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x26, 0x3a, 0x2a, 0x2a, 0x2e, 0x24, 0x24, 0x24, 0x24,
0x20, 0x20, 0x20, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x22, 0x77, 0x22, 0x08, 0x1d,
0x08, 0x22, 0x77, 0x22, 0x08, 0x1d, 0x08, 0x22, 0x77, 0x22, 0x08, 0x1d, 0x08, 0x22, 0x77, 0x22,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0xc0, 0x60, 0x21, 0x21, 0x21, 0x21, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12,
0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12,
0x21, 0x40, 0x5e, 0x40, 0x5e, 0x5e, 0x40, 0x3f, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
0x00, 0x00, 0x1e, 0xd2, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23, 0x22, 0x22,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
0x22, 0x22, 0x32, 0x2c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x40, 0x40, 0x40, 0x80, 0x80,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
0xf0, 0x0c, 0x03, 0x00, 0x00, 0x00, 0x80, 0x80, 0xe0, 0x60, 0x38, 0x30, 0x38, 0x50, 0x98, 0x10,
0x0c, 0x08, 0x0c, 0x08, 0x0c, 0x08, 0x06, 0x04, 0x06, 0x34, 0x4e, 0x4c, 0x36, 0x04, 0x06, 0x04,
0x06, 0x04, 0x06, 0x04, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x1b, 0x26, 0x27, 0x1a, 0x03, 0x02,
0x03, 0x02, 0x03, 0x02, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x36, 0x4c, 0x4e, 0x34, 0x06, 0x04,
0x06, 0x08, 0x0c, 0x08, 0x0c, 0x08, 0x0c, 0x10, 0x90, 0x58, 0x30, 0x38, 0x30, 0x70, 0xc0, 0xc0,
0x00, 0x01, 0x01, 0x02, 0x04, 0x08, 0x10, 0xe0, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
0x03, 0x1c, 0x60, 0x80, 0x80, 0x85, 0x87, 0x9f, 0x98, 0xf0, 0xe7, 0xa5, 0xa7, 0x90, 0x88, 0x87,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x87, 0x88, 0x90, 0xa7, 0xa5, 0xe7, 0xf0, 0x98, 0x9f,
0x47, 0x25, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x06, 0x04, 0x18,
0x10, 0x7c, 0x62, 0xea, 0x62, 0xdc, 0x40, 0xc0, 0x40, 0xdc, 0x62, 0xea, 0x62, 0xdc, 0x40, 0xc0,
0x40, 0xdc, 0x62, 0xea, 0x62, 0xdc, 0x40, 0xc0, 0x40, 0xdc, 0x62, 0xea, 0x62, 0xdc, 0x40, 0xc0,
0x40, 0xdc, 0x62, 0xea, 0x62, 0xdc, 0x40, 0xc0, 0x40, 0xdc, 0x62, 0xea, 0x62, 0xdc, 0x40, 0xc0,
0x40, 0xdc, 0x62, 0xea, 0x62, 0x7c, 0x10, 0x18, 0x04, 0x06, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
};
byte screen = 1; //controls which screen gets rendered
byte landY[17]; //array that saves the current terrain
byte rightY = 64; //the first y coordinate of the terrain
int tankX[] = {-8, 8, 8, -8, -8}; //array that saves the x coordinates of the tank vector
int tankY[] = {-4, -4, 4, 4, -4}; //array that saves the y coordinate of the tank vector
int eTankX[] = {-4, 4, 4, -4, -4}; //array that saves the x coordinates of the enemy vector
int eTankY[] = {-4, -4, 4, 4, -4}; //array that saves the y coordiantes of the enemy vector
int rot = 0; //saves the current tank rotation
byte tx = 0; //saves the current tank x coordinate
float ty = 0; //saves the current tank y coordiante
int wRot = 90; //saves the current gun rotation
float bulletX = 0; //bullet x coordiante
float bulletY = 0; //bullet y coordiante
boolean bulletState = false; //whether the bullet currently exists or not
int bulletDir = 0; //direction the bullet is travelling
float xspd = 3; //horizontal speed of the bullet
float yspd = 2; //vertical speed of the bullet
float gravity = 0.2; //strength of gravity that affects the bullet
float resistance = 0.05; //strength of air resistance that affects the bullet
byte enemyX = 0; //x cordiante of the enemy
byte enemyY = 0; //y cordiante of the enemy
boolean enemyState = false; //whether or not the enemy is alive curently
int enemyRot = 0; //crrent enemy rotation
byte last = 0; //the amount of points you got from the last kill
unsigned int points = 0; //the amount of points the player has
byte mortarX = 200; //x coordinate of the mortar. starts at 200 to not be visible first cycle
boolean mortarState = true; //whether the mortar is curretly warning or damaging
int timer = 0; //timer that controls how long the mortar warns and goes of for
boolean controlSheme = true; //which control sheme the player has chosen to use (true left/right for gun)
void setup() {
arduboy.begin();
arduboy.setFrameRate(30);
arduboy.initRandomSeed();
arduboy.clear();
//generates the terrain for the first level
initLand();
//spawns the enemy for the first level
spawnEnemy();
}
void loop() {
if (!(arduboy.nextFrame())) {
return;
}
arduboy.pollButtons();
arduboy.clear();
//game screen
if (screen == 0) {
toggleSound();
setEnemyRot();
destroyBulletOutOfBounds();
killEnemy();
setTankRot();
setTankY();
moveBullet();
if (controlSheme) {
moveTank();
moveGun();
} else {
moveTank2();
moveGun2();
}
shoot();
drawLand();
destroyBulletTerrainCollision();
drawMortarZone();
mortarExplode();
drawVectorRot(tx, ty, tankX, tankY, 5, 100, 100, rot);
if (enemyState) {
drawVectorRot(enemyX, enemyY, eTankX, eTankY, 5, 100, 100, enemyRot);
}
drawGun();
drawBullet();
drawUI();
}
//start screen
if (screen == 1) {
arduboy.drawBitmap(0, 0, start, 128, 64, WHITE);
if (arduboy.justPressed(A_BUTTON)) {
screen = 0;
}
if (arduboy.justPressed(B_BUTTON)) {
controlSheme = !controlSheme;
}
tinyfont.setCursor(0, 60);
if (controlSheme) {
tinyfont.print("A");
} else {
tinyfont.print("B");
}
}
//game over screen
if (screen == 2) {
arduboy.drawBitmap(0, 0, gameOver, 128, 64, WHITE);
tinyfont.setCursor(60, 18);
tinyfont.print(points);
if (arduboy.justPressed(A_BUTTON)) {
screen = 1;
points = 0;
last = 0;
}
}
arduboy.display();
}
//draws the exploded mortar and starts the timer to switc to the warning state
void mortarExplode() {
if (mortarState) {
sound.tone(70, 66);
arduboy.drawBitmap(mortarX -8, -arduboy.frameCount % 64, explosion, 16, 64, WHITE);
arduboy.drawBitmap(mortarX -8, (-arduboy.frameCount % 64) - 64, explosion, 16, 64, WHITE);
if (arduboy.frameCount - timer > 30) {
mortarX = random(tx - 16, tx + 16);
mortarState = false;
timer = arduboy.frameCount;
}
}
}
//draws the mortar warning and starts the timer to switch to the exploded state
void drawMortarZone() {
if (!mortarState) {
if (arduboy.everyXFrames(2)) {
arduboy.drawBitmap(mortarX - 8, 10, skull, 16, 16, WHITE);
}
arduboy.drawFastVLine(mortarX - 8, 6, 58, WHITE);
arduboy.drawFastVLine(mortarX + 8, 6, 58, WHITE);
if (arduboy.frameCount - timer > 60) {
mortarState = true;
timer = arduboy.frameCount;
if (tx < mortarX + 8 and tx > mortarX - 8) {
sound.tone(300, 150, 150, 150, 50, 150);
screen = 2;
}
}
}
}
//draws points
void drawUI() {
arduboy.fillRect(0, 0, 128, 5, BLACK);
tinyfont.setCursor(0, 0);
tinyfont.print("LAST:");
tinyfont.print(last);
tinyfont.setCursor(48, 0);
tinyfont.print("POINTS:");
tinyfont.print(points);
}
//destroys the bullet if a white pixel is above the bullet (only takes the pixels into account that have been drawn by this point)
void destroyBulletTerrainCollision() {
if (bulletState) {
for (int y = 0; y < bulletY; y++) {
if (arduboy.getPixel(bulletX, y) == WHITE and y <= bulletY) {
bulletState = false;
sound.tone(50, 125);
int i = bulletX / 8;
landY[i] += 4;
if (landY[i] > 63) {
landY[i] = 63;
}
return;
}
}
}
}
//destroys enemy and bullet if they collide
void killEnemy() {
if (bulletState and enemyState) {
Rect rectEnemy{enemyX - 5, enemyY - 5, 10, 10};
Point pointBullet{bulletX, bulletY};
if (arduboy.collide(pointBullet, rectEnemy)) {
last = abs(enemyX - tx);
points += last;
bulletState = false;
enemyState = false;
sound.tone(50, 100, 40, 100);
}
}
}
//destroys the bullet if it leaves the screen to the sides of bottom
void destroyBulletOutOfBounds() {
if (bulletState) {
if (bulletX > 128 or bulletX < 0) {
bulletState = false;
}
if (bulletY > 64) {
bulletState = false;
}
}
}
//calculates the rotation the enemy needs to have based on the slant of the terrain below
void setEnemyRot() {
if (enemyState) {
enemyRot = getAngle(enemyX - (enemyX % 8), landY[enemyX/8], (enemyX + 8) - (enemyX % 8), landY[(enemyX/8)+1]);
}
}
//spawns an enemy and calculates the y coordinate based on the terrain
void spawnEnemy() {
if (!enemyState) {
enemyState = true;
enemyX = random(64, 120);
byte x1 = enemyX - (enemyX % 8);
byte y1 = landY[enemyX/8];
byte x2 = (enemyX + 8) - (enemyX % 8);
byte y2 = landY[(enemyX/8)+1];
float m1 = y2 - y1;
float m2 = x2 - x1;
float m = m1/m2;
float b = y1 - (x1 * m);
float fEnemyX = enemyX;
enemyY = ((m * fEnemyX) + b)-3;
}
}
//moves the bullet in the coresponding dirction
void moveBullet() {
if (bulletState) {
bulletX = bulletX + lendirX(xspd, bulletDir);
bulletY = bulletY + lendirY(yspd, bulletDir);
}
xspd -= resistance;
yspd -= gravity;
yspd -= resistance;
if (xspd < 0) {
xspd = 0;
}
if (xspd <= 0 and yspd <= 0) {
bulletState = false;
}
}
void shoot() {
if (arduboy.justPressed(A_BUTTON)) {
if (!bulletState) {
sound.tone(750, 75);
bulletState = true;
bulletDir = rot + wRot;
bulletX = tx + lendirX(10, bulletDir);
bulletY = ty + lendirY(10, bulletDir);
xspd = 5;
yspd = 5;
}
}
}
void drawBullet() {
if (bulletState) {
//arduboy.fillCircle(bulletX, bulletY, 1, WHITE);
arduboy.drawPixel(bulletX, bulletY, WHITE);
}
}
void drawGun() {
arduboy.drawLine(tx, ty, tx + lendirX(10, rot + wRot), ty + lendirY(10, rot + wRot), WHITE);
}
//calculates the tank y coordinate based ont the terrain below
void setTankY() {
byte x1 = tx - (tx % 8);
byte y1 = landY[tx/8];
byte x2 = (tx + 8) - (tx % 8);
byte y2 = landY[(tx/8)+1];
float m1 = y2 - y1;
float m2 = x2 - x1;
float m = m1/m2;
float b = y1 - (x1 * m);
float ftx = tx;
ty = ((m * ftx) + b)-3;
}
//calculates the tank rotation based on the terrain below
void setTankRot() {
rot = getAngle(tx - (tx % 8), landY[tx/8], (tx + 8) - (tx % 8), landY[(tx/8)+1]);
}
//moves the tank and generates a new level when the screen is left to the right
void moveTank() {
if (arduboy.pressed(UP_BUTTON)) {
tx++;
}
if (arduboy.pressed(DOWN_BUTTON)) {
tx--;
}
if (tx < 8) {
tx = 8;
}
if (tx > 127) {
tx = 0;
initLand();
bulletState = false;
enemyState = false;
spawnEnemy();
mortarX = 200;
mortarState = false;
timer = arduboy.frameCount;
}
if (enemyX - tx < 10 and enemyState) {
tx--;
}
}
//same as moveTank but uses other control sheme
void moveTank2() {
if (arduboy.pressed(RIGHT_BUTTON)) {
tx++;
}
if (arduboy.pressed(LEFT_BUTTON)) {
tx--;
}
if (tx < 8) {
tx = 8;
}
if (tx > 127) {
tx = 0;
initLand();
bulletState = false;
enemyState = false;
spawnEnemy();
mortarX = 200;
mortarState = false;
timer = arduboy.frameCount;
}
if (enemyX - tx < 10 and enemyState) {
tx--;
}
}
//generates the terrain
void initLand() {
byte lastY = rightY;
for (int i = 0; i < 17; i++) {
landY[i] = lastY;
lastY += random(-8, 9);
if (lastY < 16) {
lastY = 16;
}
if (lastY > 63) {
lastY = 63;
}
}
rightY = landY[16];
}
//rotates the gun
void moveGun() {
if (arduboy.pressed(RIGHT_BUTTON)) {
wRot -= 1;
}
if (arduboy.pressed(LEFT_BUTTON)) {
wRot += 1;
}
if (wRot > 180) {
wRot = 180;
}
if (wRot < 0) {
wRot = 0;
}
}
//same as moveGun but with ither control sheme
void moveGun2() {
if (arduboy.pressed(UP_BUTTON)) {
wRot += 1;
}
if (arduboy.pressed(DOWN_BUTTON)) {
wRot -= 1;
}
if (wRot > 90) {
wRot = 90;
}
if (wRot < 1) {
wRot = 1;
}
}
void drawLand() {
for (int i = 0; i < 16; i++) {
arduboy.drawLine(8 * i, landY[i], 8 * (i+1), landY[i+1], WHITE);
}
}
//calculates the x coordinate of a point based on the direction and distance of that point (relative to 0,0)
float lendirX(int len, int dir) {
dir = ((dir % 360) + 360) % 360;
dir = dir - 360;
if (dir < 90) {
return (cos(dir * (3.14159265359f / 180.0f)) * len);
}
if (dir > 90 and dir < 180) {
return -(cos(dir * (3.14159265359f / 180.0f)) * len);
}
if (dir > 180 and dir < 270) {
return -(cos(dir * (3.14159265359f / 180.0f)) * len);
}
if (dir > 270) {
return (cos(dir * (3.14159265359f / 180.0f)) * len);
}
if (dir == 0 or dir == 360) {
return len;
}
if (dir == 90 or dir == 270) {
return 0;
}
if (dir == 180) {
return - len;
}
}
//calculates the y coordinate of a point based on the direction and distance of that point (relative to 0,0)
float lendirY(int len, int dir) {
dir = ((dir % 360) + 360) % 360;
dir = dir - 360;
if (dir < 90) {
return -(sin(dir * (3.14159265359f / 180.0f)) * len);
}
if (dir > 90 and dir < 180) {
return -(sin(dir * (3.14159265359f / 180.0f)) * len);
}
if (dir > 180 and dir < 270) {
return (sin(dir * (3.14159265359f / 180.0f)) * len);
}
if (dir > 270) {
return (sin(dir * (3.14159265359f / 180.0f)) * len);
}
if (dir == 0 or dir == 360 or dir == 180) {
return 0;
}
if (dir == 90) {
return - len;
}
if (dir == 270) {
return len;
}
}
//draws a vector with x array, y array, x coordiante, y coordiante, number of elemtns in array, xscale, yscale, roation
void drawVectorRot(int xc, int yc, int x[], int y[],byte len, int xscale, int yscale, int rot) {
for (int i = 0; i <= len-2; i++) {
int leni = getDistance(0, 0, x[i], y[i]);
int diri = getAngle(0, 0, x[i], y[i]);
int lenii = getDistance(0, 0, x[i+1], y[i+1]);
int dirii = getAngle(0, 0, x[i+1], y[i+1]);
arduboy.drawLine(xc + lendirX(leni * xscale/100, diri + rot), yc + lendirY(leni * yscale/100, diri + rot), xc + lendirX(lenii * xscale/100, dirii + rot), yc + lendirY(lenii * yscale/100, dirii + rot), WHITE);
}
}
//gets the distance between 2 points
byte getDistance(int x1, int y1, int x2, int y2) {
int dx = max(x1, x2) - min(x1, x2);
int dy = max(y1, y2) - min(y1, y2);
return sqrt(sq(dx) + sq(dy));
}
//gets the angle between 2 points relative to horizontal
int getAngle(int x1, int y1, int x2, int y2) {
int angle = (atan2(y1 - y2, x1 - x2) * 180 / 3.14159265359f);
angle = (((-(angle + 180)) % 360)+ 360)% 360;
return angle;
}
//toggles the sound between on and off and saves the current state
void toggleSound() {
if (arduboy.justPressed(B_BUTTON)) {
arduboy.audio.toggle();
sound.tone(1000, 50);
arduboy.audio.saveOnOff();
}
}