@@ -90,25 +90,28 @@ void setup() {
9090 // initialize
9191
9292 Serial.println (" Hello! Arcada version of game" );
93- if (!arcada.begin ()) {
93+ if (!arcada.arcadaBegin ()) {
9494 Serial.print (" Failed to begin" );
9595 strip.fill (RED);
9696 strip.show ();
9797 while (1 );
9898 }
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+
99109 if ( !arcada.hasAccel () ) {
100110 strip.fill (YELLOW);
101111 strip.show ();
102112 arcada.haltBox (" An accelerometer is required for this gamne" );
103113 }
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+
112115 // Set up the logo bitmap
113116 int logo_origin_x = (128 - 2 *LOGO_WIDTH ) / 2 ;
114117 int logo_origin_y = (160 - 2 *LOGO_HEIGHT) / 2 ;
@@ -118,34 +121,34 @@ void setup() {
118121 if (c & (0x80 >> (x & 7 ))) {
119122 int xx = logo_origin_x+2 *x;
120123 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);
125128 }
126129 }
127130 }
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" );
138141 for (int i=0 ; i<220 ; i++) { // Display initial text
139142 arcada.setBacklight (i);
140143 delay (14 );
141144 }
142145 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" );
147150 while (!(arcada.readButtons () & ARCADA_BUTTONMASK_START)) ; // wait for start button
148- arcada.fillScreen (background); // Clear screen
151+ arcada.display -> fillScreen (background); // Clear screen
149152
150153 arcada.enableSpeaker (1 ); // Enable the speaker and play opening tones
151154 pinMode (sound_pin, OUTPUT);
@@ -187,7 +190,7 @@ void loop() {
187190
188191int acc_avg (int pin) {
189192 int avg = 0 ;
190- arcada.accel . getEvent (&event);
193+ arcada.accel -> getEvent (&event);
191194 switch (pin) {
192195 case acc_pinX:
193196 for (int i = 0 ; i < 50 ; i++) {
@@ -214,7 +217,7 @@ int acc_avg(int pin) {
214217
215218int acc_readX () {
216219 int val;
217- arcada.accel . getEvent (&event);
220+ arcada.accel -> getEvent (&event);
218221 val = -1 * constrain ((event.acceleration .y - acc_avgY)*7 , -64 , 64 ); // use Y for orientation
219222 // Serial.print("Acceleration: "); // joystick is at top
220223 // Serial.println(val);
@@ -241,17 +244,17 @@ void BonusReset(){
241244 nextBonus = random (30 , 60 );
242245 b_pendingPlatform = false ;
243246 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);
246249 EndUseBonus ();
247250}
248251
249252void ClearBonus (){
250253 EndUseBonus ();
251254 b_remaining = 0 ;
252255 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);
255258 b_used = false ;
256259}
257260
@@ -261,7 +264,7 @@ void GetBonus(){
261264 b_pendingPlatform = false ;
262265 beep (sound_pin, 3500 , 50 ); // SOUND
263266 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);
265268
266269 switch (b_onUseID){
267270 case 0 :
@@ -286,19 +289,19 @@ void GetBonus(){
286289 break ;
287290 }
288291 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]);
291294 }
292295}
293296
294297void UseBonus (){
295298 if (b_remaining){
296299 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);
299302 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]);
302305
303306 switch (b_onUseID){
304307 case 0 :
@@ -378,20 +381,20 @@ void CheckButtons(){
378381 drawChar (s_width-6 , textline2, speaker_icon, ARCADA_RED); // Put character in lower right corner to indicate speaker off
379382 } else {
380383 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
382385 }
383386 }
384387}
385388
386389void DrawPlayer (){
387390 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
389392 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);
391394
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
393396 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);
395398}
396399
397400void MovePlayer (){
@@ -429,7 +432,7 @@ void CollideBorders() {
429432 }
430433 }
431434 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);
433436 p_width--;
434437 p_height--;
435438 b_lives--;
@@ -439,8 +442,8 @@ void CollideBorders() {
439442}
440443
441444void 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);
444447 // highscore = EEPROM.read(0);
445448 // highscore += (EEPROM.read(1)<<8);
446449 if (highscore > 64000 ){
@@ -478,11 +481,11 @@ void ScoreReset(){
478481
479482void flashMessage () {
480483 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);
482485 for (i=0 ; i<5 ; i++) {
483486 drawString (1 , textline2, " HIGHSCORE!" , p_color_default, 1 );
484487 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);
486489 delay (400 );
487490 }
488491 drawString (1 , textline2, " High score:" , w_color, 1 );
@@ -507,7 +510,7 @@ void ScoreAdd(){ // add to the current score lower left
507510
508511// transform from int to string and display it
509512void 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);
511514 drawChar (nx+24 , ny, 48 +(num%10 ), color);
512515
513516 if (num > 9 ) {
@@ -593,26 +596,26 @@ void CollideWorld() {
593596
594597void DrawWorld () {
595598 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);
598601 }
599602 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]);
601604 }
602605}
603606
604607
605608void 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);
610613}
611614
612615void 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);
616619 Serial.println (text);
617620}
618621
0 commit comments