@@ -90,25 +90,28 @@ void setup() {
90
90
// initialize
91
91
92
92
Serial.println (" Hello! Arcada version of game" );
93
- if (!arcada.begin ()) {
93
+ if (!arcada.arcadaBegin ()) {
94
94
Serial.print (" Failed to begin" );
95
95
strip.fill (RED);
96
96
strip.show ();
97
97
while (1 );
98
98
}
99
+
100
+ arcada.displayBegin (); // Initialize display code
101
+ arcada.setBacklight (0 ); // Initial display off
102
+ arcada.display ->setRotation (0 ); // Rotate to portrait
103
+ arcada.display ->fillScreen (background); // Clear screen if necessary
104
+ arcada.display ->setTextColor (ARCADA_GREEN, ARCADA_BLACK);
105
+ arcada.display ->setTextSize (2 );
106
+ arcada.display ->println (" " );
107
+ arcada.display ->println (" Bounce!" );
108
+
99
109
if ( !arcada.hasAccel () ) {
100
110
strip.fill (YELLOW);
101
111
strip.show ();
102
112
arcada.haltBox (" An accelerometer is required for this gamne" );
103
113
}
104
- arcada.displayBegin (); // Initialize display code
105
- arcada.setBacklight (0 ); // Initial display off
106
- arcada.setRotation (0 ); // Rotate to portrait
107
- arcada.fillScreen (background); // Clear screen if necessary
108
- arcada.setTextColor (ARCADA_GREEN, ARCADA_BLACK);
109
- arcada.setTextSize (2 );
110
- arcada.println (" " );
111
- arcada.println (" Bounce!" );
114
+
112
115
// Set up the logo bitmap
113
116
int logo_origin_x = (128 - 2 *LOGO_WIDTH ) / 2 ;
114
117
int logo_origin_y = (160 - 2 *LOGO_HEIGHT) / 2 ;
@@ -118,34 +121,34 @@ void setup() {
118
121
if (c & (0x80 >> (x & 7 ))) {
119
122
int xx = logo_origin_x+2 *x;
120
123
int yy = logo_origin_y+2 *y;
121
- arcada.drawPixel (xx, yy, ARCADA_WHITE);
122
- arcada.drawPixel (xx+1 , yy, ARCADA_WHITE);
123
- arcada.drawPixel (xx, yy+1 , ARCADA_WHITE);
124
- arcada.drawPixel (xx+1 , yy+1 , ARCADA_WHITE);
124
+ arcada.display -> drawPixel (xx, yy, ARCADA_WHITE);
125
+ arcada.display -> drawPixel (xx+1 , yy, ARCADA_WHITE);
126
+ arcada.display -> drawPixel (xx, yy+1 , ARCADA_WHITE);
127
+ arcada.display -> drawPixel (xx+1 , yy+1 , ARCADA_WHITE);
125
128
}
126
129
}
127
130
}
128
- arcada.println (" " );
129
- arcada.println (" " );
130
- arcada.println (" " );
131
- arcada.println (" " );
132
- arcada.println (" " );
133
- arcada.setTextColor (ARCADA_ORANGE, ARCADA_BLACK);
134
- arcada.setTextSize (1 );
135
- arcada.println (" " );
136
- arcada.println (" Adafruit" );
137
- arcada.println (" Industries" );
131
+ arcada.display -> println (" " );
132
+ arcada.display -> println (" " );
133
+ arcada.display -> println (" " );
134
+ arcada.display -> println (" " );
135
+ arcada.display -> println (" " );
136
+ arcada.display -> setTextColor (ARCADA_ORANGE, ARCADA_BLACK);
137
+ arcada.display -> setTextSize (1 );
138
+ arcada.display -> println (" " );
139
+ arcada.display -> println (" Adafruit" );
140
+ arcada.display -> println (" Industries" );
138
141
for (int i=0 ; i<220 ; i++) { // Display initial text
139
142
arcada.setBacklight (i);
140
143
delay (14 );
141
144
}
142
145
arcada.setBacklight (250 );
143
- arcada.setTextColor (ST7735_WHITE, ST7735_BLACK);
144
- arcada.println (" " );
145
- arcada.println (" " );
146
- arcada.println (" Press Start" );
146
+ arcada.display -> setTextColor (ST7735_WHITE, ST7735_BLACK);
147
+ arcada.display -> println (" " );
148
+ arcada.display -> println (" " );
149
+ arcada.display -> println (" Press Start" );
147
150
while (!(arcada.readButtons () & ARCADA_BUTTONMASK_START)) ; // wait for start button
148
- arcada.fillScreen (background); // Clear screen
151
+ arcada.display -> fillScreen (background); // Clear screen
149
152
150
153
arcada.enableSpeaker (1 ); // Enable the speaker and play opening tones
151
154
pinMode (sound_pin, OUTPUT);
@@ -187,7 +190,7 @@ void loop() {
187
190
188
191
int acc_avg (int pin) {
189
192
int avg = 0 ;
190
- arcada.accel . getEvent (&event);
193
+ arcada.accel -> getEvent (&event);
191
194
switch (pin) {
192
195
case acc_pinX:
193
196
for (int i = 0 ; i < 50 ; i++) {
@@ -214,7 +217,7 @@ int acc_avg(int pin) {
214
217
215
218
int acc_readX () {
216
219
int val;
217
- arcada.accel . getEvent (&event);
220
+ arcada.accel -> getEvent (&event);
218
221
val = -1 * constrain ((event.acceleration .y - acc_avgY)*7 , -64 , 64 ); // use Y for orientation
219
222
// Serial.print("Acceleration: "); // joystick is at top
220
223
// Serial.println(val);
@@ -241,17 +244,17 @@ void BonusReset(){
241
244
nextBonus = random (30 , 60 );
242
245
b_pendingPlatform = false ;
243
246
b_remaining = 0 ;
244
- arcada.fillRect (0 , s_height+2 , 96 , 10 , background);
245
- arcada.fillRect (0 , s_height+1 , 96 , 1 , w_color);
247
+ arcada.display -> fillRect (0 , s_height+2 , 96 , 10 , background);
248
+ arcada.display -> fillRect (0 , s_height+1 , 96 , 1 , w_color);
246
249
EndUseBonus ();
247
250
}
248
251
249
252
void ClearBonus (){
250
253
EndUseBonus ();
251
254
b_remaining = 0 ;
252
255
p_color = p_color_default;
253
- arcada.fillRect (0 , s_height+2 , 96 , 10 , background);
254
- arcada.fillRect (0 , s_height+1 , s_width-1 , 1 , w_color);
256
+ arcada.display -> fillRect (0 , s_height+2 , 96 , 10 , background);
257
+ arcada.display -> fillRect (0 , s_height+1 , s_width-1 , 1 , w_color);
255
258
b_used = false ;
256
259
}
257
260
@@ -261,7 +264,7 @@ void GetBonus(){
261
264
b_pendingPlatform = false ;
262
265
beep (sound_pin, 3500 , 50 ); // SOUND
263
266
p_color = b_colors[b_onUseID];
264
- arcada.fillRect (0 , s_height+2 , 96 , 10 , background);
267
+ arcada.display -> fillRect (0 , s_height+2 , 96 , 10 , background);
265
268
266
269
switch (b_onUseID){
267
270
case 0 :
@@ -286,19 +289,19 @@ void GetBonus(){
286
289
break ;
287
290
}
288
291
if (b_remaining > 1 ) {
289
- arcada.fillRect (95 , s_height+2 , 1 , 10 , b_colors[b_onUseID]);
290
- arcada.fillRect ( 0 , s_height+1 , 95 , 1 , b_colors[b_onUseID]);
292
+ arcada.display -> fillRect (95 , s_height+2 , 1 , 10 , b_colors[b_onUseID]);
293
+ arcada.display -> fillRect ( 0 , s_height+1 , 95 , 1 , b_colors[b_onUseID]);
291
294
}
292
295
}
293
296
294
297
void UseBonus (){
295
298
if (b_remaining){
296
299
b_used = true ;
297
- arcada.fillRect (b_remaining*95 /b_max, s_height+2 , 1 , 10 , background);
298
- arcada.drawPixel (b_remaining*95 /b_max, s_height+1 , w_color);
300
+ arcada.display -> fillRect (b_remaining*95 /b_max, s_height+2 , 1 , 10 , background);
301
+ arcada.display -> drawPixel (b_remaining*95 /b_max, s_height+1 , w_color);
299
302
b_remaining --;
300
- arcada.fillRect (b_remaining*95 /b_max, s_height+2 , 1 , 10 , b_colors[b_onUseID]);
301
- arcada.drawPixel (b_remaining*95 /b_max, s_height+1 , b_colors[b_onUseID]);
303
+ arcada.display -> fillRect (b_remaining*95 /b_max, s_height+2 , 1 , 10 , b_colors[b_onUseID]);
304
+ arcada.display -> drawPixel (b_remaining*95 /b_max, s_height+1 , b_colors[b_onUseID]);
302
305
303
306
switch (b_onUseID){
304
307
case 0 :
@@ -378,20 +381,20 @@ void CheckButtons(){
378
381
drawChar (s_width-6 , textline2, speaker_icon, ARCADA_RED); // Put character in lower right corner to indicate speaker off
379
382
} else {
380
383
sound_on = 1 ;
381
- arcada.fillRect ( s_width-6 , textline2, s_width-1 , textline2+9 , background); // Blank lower right character = sound on
384
+ arcada.display -> fillRect ( s_width-6 , textline2, s_width-1 , textline2+9 , background); // Blank lower right character = sound on
382
385
}
383
386
}
384
387
}
385
388
386
389
void DrawPlayer (){
387
390
CheckButtons (); // check more frequently
388
- arcada.fillRect (p_lastX, p_lastY, p_width, p_height, background); // erase previous pos
391
+ arcada.display -> fillRect (p_lastX, p_lastY, p_width, p_height, background); // erase previous pos
389
392
if (p_lastX > (s_width-1 - p_width)) // if across the edge of the screen
390
- arcada.fillRect (0 , p_lastY, p_lastX + p_width - s_width, p_height, background);
393
+ arcada.display -> fillRect (0 , p_lastY, p_lastX + p_width - s_width, p_height, background);
391
394
392
- arcada.fillRect (p_X, p_Y, p_width, p_height, p_color); // draw new pos
395
+ arcada.display -> fillRect (p_X, p_Y, p_width, p_height, p_color); // draw new pos
393
396
if (p_X > (s_width-1 - p_width)) // if across the edge of the screen
394
- arcada.fillRect (0 , p_Y, p_X + p_width - s_width, p_height, p_color);
397
+ arcada.display -> fillRect (0 , p_Y, p_X + p_width - s_width, p_height, p_color);
395
398
}
396
399
397
400
void MovePlayer (){
@@ -429,7 +432,7 @@ void CollideBorders() {
429
432
}
430
433
}
431
434
else {
432
- arcada.fillRect (p_lastX, p_lastY, p_width, p_height, background);
435
+ arcada.display -> fillRect (p_lastX, p_lastY, p_width, p_height, background);
433
436
p_width--;
434
437
p_height--;
435
438
b_lives--;
@@ -439,8 +442,8 @@ void CollideBorders() {
439
442
}
440
443
441
444
void ScoreSetup (){
442
- arcada.fillRect (0 , s_height+2 , 128 , 10 , background);
443
- arcada.fillRect (0 , s_height+1 , 128 , 1 , w_color);
445
+ arcada.display -> fillRect (0 , s_height+2 , 128 , 10 , background);
446
+ arcada.display -> fillRect (0 , s_height+1 , 128 , 1 , w_color);
444
447
// highscore = EEPROM.read(0);
445
448
// highscore += (EEPROM.read(1)<<8);
446
449
if (highscore > 64000 ){
@@ -478,11 +481,11 @@ void ScoreReset(){
478
481
479
482
void flashMessage () {
480
483
uint8_t i;
481
- arcada.fillRect ( 0 , textline2, s_width-10 , textline2+9 , background);
484
+ arcada.display -> fillRect ( 0 , textline2, s_width-10 , textline2+9 , background);
482
485
for (i=0 ; i<5 ; i++) {
483
486
drawString (1 , textline2, " HIGHSCORE!" , p_color_default, 1 );
484
487
delay (400 );
485
- arcada.fillRect ( 0 , textline2, s_width-10 , textline2+9 , background);
488
+ arcada.display -> fillRect ( 0 , textline2, s_width-10 , textline2+9 , background);
486
489
delay (400 );
487
490
}
488
491
drawString (1 , textline2, " High score:" , w_color, 1 );
@@ -507,7 +510,7 @@ void ScoreAdd(){ // add to the current score lower left
507
510
508
511
// transform from int to string and display it
509
512
void drawInt (unsigned int num, byte nx, byte ny, unsigned int color, unsigned int color2) {
510
- arcada.fillRect (nx, ny, 29 , 7 , color2);
513
+ arcada.display -> fillRect (nx, ny, 29 , 7 , color2);
511
514
drawChar (nx+24 , ny, 48 +(num%10 ), color);
512
515
513
516
if (num > 9 ) {
@@ -593,26 +596,26 @@ void CollideWorld() {
593
596
594
597
void DrawWorld () {
595
598
for (byte i=0 ; i<w_size; i++) {
596
- arcada.fillRect (world[i][2 ], world[i][3 ], world[i][5 ], 1 , background);
597
- arcada.fillRect (world[i][0 ], world[i][1 ], world[i][4 ], 1 , w_color);
599
+ arcada.display -> fillRect (world[i][2 ], world[i][3 ], world[i][5 ], 1 , background);
600
+ arcada.display -> fillRect (world[i][0 ], world[i][1 ], world[i][4 ], 1 , w_color);
598
601
}
599
602
if (b_pendingPlatform){
600
- arcada.fillRect (world[b_platformID][0 ], world[b_platformID][1 ], world[b_platformID][4 ], 1 , b_colors[b_pendingID]);
603
+ arcada.display -> fillRect (world[b_platformID][0 ], world[b_platformID][1 ], world[b_platformID][4 ], 1 , b_colors[b_pendingID]);
601
604
}
602
605
}
603
606
604
607
605
608
void drawString (byte x, byte y, char *text, uint16_t color, bool wrap) { // replicate tft.drawString
606
- arcada.setCursor (x,y);
607
- arcada.setTextColor (color);
608
- arcada.setTextWrap (wrap);
609
- arcada.print (text);
609
+ arcada.display -> setCursor (x,y);
610
+ arcada.display -> setTextColor (color);
611
+ arcada.display -> setTextWrap (wrap);
612
+ arcada.display -> print (text);
610
613
}
611
614
612
615
void drawChar (byte x, byte y, char text, uint16_t color) { // replicate tft.drawChar
613
- arcada.setCursor (x,y);
614
- arcada.setTextColor (color);
615
- arcada.print (text);
616
+ arcada.display -> setCursor (x,y);
617
+ arcada.display -> setTextColor (color);
618
+ arcada.display -> print (text);
616
619
Serial.println (text);
617
620
}
618
621
0 commit comments