mirror of https://github.com/MLXXXp/Arduboy2.git
ardubreakout should use new separate print class
This commit is contained in:
parent
2223f5e835
commit
8eb4deed69
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
Arduboy arduboy;
|
Arduboy arduboy;
|
||||||
ArduboyPlaytune tunes;
|
ArduboyPlaytune tunes;
|
||||||
|
AbPrinter text(arduboy);
|
||||||
|
|
||||||
const unsigned int COLUMNS = 13; //Columns of bricks
|
const unsigned int COLUMNS = 13; //Columns of bricks
|
||||||
const unsigned int ROWS = 4; //Rows of bricks
|
const unsigned int ROWS = 4; //Rows of bricks
|
||||||
|
@ -34,7 +35,7 @@ unsigned int score=0; //Score for the game
|
||||||
unsigned int brickCount; //Amount of bricks hit
|
unsigned int brickCount; //Amount of bricks hit
|
||||||
byte pad,pad2,pad3; //Button press buffer used to stop pause repeating
|
byte pad,pad2,pad3; //Button press buffer used to stop pause repeating
|
||||||
byte oldpad,oldpad2,oldpad3;
|
byte oldpad,oldpad2,oldpad3;
|
||||||
char text[16]; //General string buffer
|
char text_buffer[16]; //General string buffer
|
||||||
boolean start=false; //If in menu or in game
|
boolean start=false; //If in menu or in game
|
||||||
boolean initialDraw=false;//If the inital draw has happened
|
boolean initialDraw=false;//If the inital draw has happened
|
||||||
char initials[3]; //Initials used in high score
|
char initials[3]; //Initials used in high score
|
||||||
|
@ -313,9 +314,9 @@ void moveBall()
|
||||||
|
|
||||||
void drawBall()
|
void drawBall()
|
||||||
{
|
{
|
||||||
// arduboy.setCursor(0,0);
|
// text.setCursor(0,0);
|
||||||
// arduboy.print(arduboy.cpuLoad());
|
// text.print(arduboy.cpuLoad());
|
||||||
// arduboy.print(" ");
|
// text.print(" ");
|
||||||
arduboy.drawPixel(xb, yb, 0);
|
arduboy.drawPixel(xb, yb, 0);
|
||||||
arduboy.drawPixel(xb+1, yb, 0);
|
arduboy.drawPixel(xb+1, yb, 0);
|
||||||
arduboy.drawPixel(xb, yb+1, 0);
|
arduboy.drawPixel(xb, yb+1, 0);
|
||||||
|
@ -338,9 +339,9 @@ void drawPaddle()
|
||||||
|
|
||||||
void drawLives()
|
void drawLives()
|
||||||
{
|
{
|
||||||
sprintf(text, "LIVES:%u", lives);
|
sprintf(text_buffer, "LIVES:%u", lives);
|
||||||
arduboy.setCursor(0, 90);
|
text.setCursor(0, 90);
|
||||||
arduboy.print(text);
|
text.print(text_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawGameOver()
|
void drawGameOver()
|
||||||
|
@ -349,10 +350,10 @@ void drawGameOver()
|
||||||
arduboy.drawPixel(xb+1, yb, 0);
|
arduboy.drawPixel(xb+1, yb, 0);
|
||||||
arduboy.drawPixel(xb, yb+1, 0);
|
arduboy.drawPixel(xb, yb+1, 0);
|
||||||
arduboy.drawPixel(xb+1, yb+1, 0);
|
arduboy.drawPixel(xb+1, yb+1, 0);
|
||||||
arduboy.setCursor(52, 42);
|
text.setCursor(52, 42);
|
||||||
arduboy.print( "Game");
|
text.print( "Game");
|
||||||
arduboy.setCursor(52, 54);
|
text.setCursor(52, 54);
|
||||||
arduboy.print("Over");
|
text.print("Over");
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
delay(4000);
|
delay(4000);
|
||||||
}
|
}
|
||||||
|
@ -361,8 +362,8 @@ void pause()
|
||||||
{
|
{
|
||||||
paused = true;
|
paused = true;
|
||||||
//Draw pause to the screen
|
//Draw pause to the screen
|
||||||
arduboy.setCursor(52, 45);
|
text.setCursor(52, 45);
|
||||||
arduboy.print("PAUSE");
|
text.print("PAUSE");
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
while (paused)
|
while (paused)
|
||||||
{
|
{
|
||||||
|
@ -382,9 +383,9 @@ void pause()
|
||||||
void Score()
|
void Score()
|
||||||
{
|
{
|
||||||
score += (level*10);
|
score += (level*10);
|
||||||
sprintf(text, "SCORE:%u", score);
|
sprintf(text_buffer, "SCORE:%u", score);
|
||||||
arduboy.setCursor(80, 90);
|
text.setCursor(80, 90);
|
||||||
arduboy.print(text);
|
text.print(text_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void newLevel(){
|
void newLevel(){
|
||||||
|
@ -416,9 +417,9 @@ void newLevel(){
|
||||||
drawLives();
|
drawLives();
|
||||||
|
|
||||||
//Draws the initial score
|
//Draws the initial score
|
||||||
sprintf(text, "SCORE:%u", score);
|
sprintf(text_buffer, "SCORE:%u", score);
|
||||||
arduboy.setCursor(80, 90);
|
text.setCursor(80, 90);
|
||||||
arduboy.print(text);
|
text.print(text_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Used to delay images while reading button input
|
//Used to delay images while reading button input
|
||||||
|
@ -448,15 +449,15 @@ boolean displayHighScores(byte file)
|
||||||
int address = file*10*5;
|
int address = file*10*5;
|
||||||
byte hi, lo;
|
byte hi, lo;
|
||||||
arduboy.clear();
|
arduboy.clear();
|
||||||
arduboy.setCursor(32, 0);
|
text.setCursor(32, 0);
|
||||||
arduboy.print("HIGH SCORES");
|
text.print("HIGH SCORES");
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
|
|
||||||
for(int i = 0; i < 10; i++)
|
for(int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
sprintf(text, "%2d", i+1);
|
sprintf(text_buffer, "%2d", i+1);
|
||||||
arduboy.setCursor(x,y+(i*8));
|
text.setCursor(x,y+(i*8));
|
||||||
arduboy.print( text);
|
text.print(text_buffer);
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
hi = EEPROM.read(address + (5*i));
|
hi = EEPROM.read(address + (5*i));
|
||||||
lo = EEPROM.read(address + (5*i) + 1);
|
lo = EEPROM.read(address + (5*i) + 1);
|
||||||
|
@ -476,9 +477,9 @@ boolean displayHighScores(byte file)
|
||||||
|
|
||||||
if (score > 0)
|
if (score > 0)
|
||||||
{
|
{
|
||||||
sprintf(text, "%c%c%c %u", initials[0], initials[1], initials[2], score);
|
sprintf(text_buffer, "%c%c%c %u", initials[0], initials[1], initials[2], score);
|
||||||
arduboy.setCursor(x + 24, y + (i*8));
|
text.setCursor(x + 24, y + (i*8));
|
||||||
arduboy.print(text);
|
text.print(text_buffer);
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,10 +495,10 @@ boolean titleScreen()
|
||||||
{
|
{
|
||||||
//Clears the screen
|
//Clears the screen
|
||||||
arduboy.clear();
|
arduboy.clear();
|
||||||
arduboy.setCursor(16,22);
|
text.setCursor(16,22);
|
||||||
arduboy.setTextSize(2);
|
text.setSize(2);
|
||||||
arduboy.print("ARAKNOID");
|
text.print("ARAKNOID");
|
||||||
arduboy.setTextSize(1);
|
text.setSize(1);
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
if (pollFireButton(25))
|
if (pollFireButton(25))
|
||||||
{
|
{
|
||||||
|
@ -509,8 +510,8 @@ boolean titleScreen()
|
||||||
{
|
{
|
||||||
//Draws "Press FIRE"
|
//Draws "Press FIRE"
|
||||||
//arduboy.bitmap(31, 53, fire); arduboy.display();
|
//arduboy.bitmap(31, 53, fire); arduboy.display();
|
||||||
arduboy.setCursor(31, 53);
|
text.setCursor(31, 53);
|
||||||
arduboy.print("PRESS FIRE!");
|
text.print("PRESS FIRE!");
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
|
|
||||||
if (pollFireButton(50))
|
if (pollFireButton(50))
|
||||||
|
@ -519,10 +520,10 @@ boolean titleScreen()
|
||||||
}
|
}
|
||||||
//Removes "Press FIRE"
|
//Removes "Press FIRE"
|
||||||
arduboy.clear();
|
arduboy.clear();
|
||||||
arduboy.setCursor(16,22);
|
text.setCursor(16,22);
|
||||||
arduboy.setTextSize(2);
|
text.setSize(2);
|
||||||
arduboy.print("ARAKNOID");
|
text.print("ARAKNOID");
|
||||||
arduboy.setTextSize(1);
|
text.setSize(1);
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
|
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
|
@ -551,17 +552,17 @@ void enterInitials()
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
arduboy.clear();
|
arduboy.clear();
|
||||||
|
|
||||||
arduboy.setCursor(16,0);
|
text.setCursor(16,0);
|
||||||
arduboy.print("HIGH SCORE");
|
text.print("HIGH SCORE");
|
||||||
sprintf(text, "%u", score);
|
sprintf(text_buffer, "%u", score);
|
||||||
arduboy.setCursor(88, 0);
|
text.setCursor(88, 0);
|
||||||
arduboy.print(text);
|
text.print(text_buffer);
|
||||||
arduboy.setCursor(56, 20);
|
text.setCursor(56, 20);
|
||||||
arduboy.print(initials[0]);
|
text.print(initials[0]);
|
||||||
arduboy.setCursor(64, 20);
|
text.setCursor(64, 20);
|
||||||
arduboy.print(initials[1]);
|
text.print(initials[1]);
|
||||||
arduboy.setCursor(72, 20);
|
text.setCursor(72, 20);
|
||||||
arduboy.print(initials[2]);
|
text.print(initials[2]);
|
||||||
for(byte i = 0; i < 3; i++)
|
for(byte i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
arduboy.drawLine(56 + (i*8), 27, 56 + (i*8) + 6, 27, 1);
|
arduboy.drawLine(56 + (i*8), 27, 56 + (i*8) + 6, 27, 1);
|
||||||
|
|
Loading…
Reference in New Issue