diff options
Diffstat (limited to 'arduino_sketch')
-rw-r--r-- | arduino_sketch/arcerino/arcerino.ino | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/arduino_sketch/arcerino/arcerino.ino b/arduino_sketch/arcerino/arcerino.ino index 7b9662e..b647fab 100644 --- a/arduino_sketch/arcerino/arcerino.ino +++ b/arduino_sketch/arcerino/arcerino.ino @@ -13,6 +13,15 @@ U8GLIB_TLS8204_84X48 u8g(15, 16, 13, 4, 5); // SPI Com: SCK = 13, MO #define LCD_0X 42 #define LCD_0Y 24 +#define TOP_TEXT_Y 8 +#define MIDDLE_TEXT_Y 24 +#define BOTTOM_TEXT_Y 46 + +#define LOAD_TEXT_X 30 + +#define FONT_SMALL u8g_font_5x7 +#define FONT_BIG u8g_font_9x15 + char x,y=0; char drift_x,drift_y=0; @@ -20,54 +29,49 @@ char score=0; char arrows=10; bool play=true; -void draw_game() { - u8g.setFont(u8g_font_5x7); - u8g.setPrintPos(0,8); +void draw_board() { + u8g.setFont(FONT_SMALL); + u8g.setPrintPos(0,TOP_TEXT_Y); u8g.print(score,DEC); - u8g.setPrintPos(0,16); + u8g.setPrintPos(0,BOTTOM_TEXT_Y); u8g.print("->"); u8g.print(arrows,DEC); - u8g.drawCircle(42,24,24); - u8g.drawCircle(42,24,16); - u8g.drawCircle(42,24,8); - u8g.drawCircle(42,24,4); + u8g.drawCircle(LCD_0X,LCD_0Y,LCD_MAX); + u8g.drawCircle(LCD_0X,LCD_0Y,LCD_MAX*2/3); + u8g.drawCircle(LCD_0X,LCD_0Y,LCD_MAX/3); + u8g.drawCircle(LCD_0X,LCD_0Y,LCD_MAX/6); +} + +void draw_game() { + draw_board(); u8g.drawVLine(x+LCD_0X,y-4+LCD_0Y,9); u8g.drawHLine(x-4+LCD_0X,y+LCD_0Y,9); } void draw_score() { - u8g.setFont(u8g_font_5x7); - u8g.setPrintPos(0,8); - u8g.print(score,DEC); - u8g.setPrintPos(0,16); - u8g.print("->"); - u8g.print(arrows,DEC); - u8g.drawCircle(42,24,24); - u8g.drawCircle(42,24,16); - u8g.drawCircle(42,24,8); - u8g.drawCircle(42,24,4); + draw_board(); u8g.drawDisc(x+LCD_0X,y+LCD_0Y,3); } void draw_title() { - u8g.setFont(u8g_font_9x15); - u8g.setPrintPos(0,24); + u8g.setFont(FONT_BIG); + u8g.setPrintPos(0,MIDDLE_TEXT_Y); u8g.print("Arcerino"); - u8g.setFont(u8g_font_5x7); - u8g.setPrintPos(30,46); + u8g.setFont(FONT_SMALL); + u8g.setPrintPos(LOAD_TEXT_X,BOTTOM_TEXT_Y); u8g.print("Loading..."); } void draw_wait() { - u8g.setFont(u8g_font_5x7); - u8g.setPrintPos(0,8); + u8g.setFont(FONT_SMALL); + u8g.setPrintPos(0,TOP_TEXT_Y); u8g.print("Your score: "); u8g.print(score,DEC); - u8g.setPrintPos(0,46); + u8g.setPrintPos(0,BOTTOM_TEXT_Y); u8g.print("Press Z to start"); - u8g.setPrintPos(0,24); + u8g.setPrintPos(0,MIDDLE_TEXT_Y); u8g.print("Rank: "); - u8g.setFont(u8g_font_9x15); + u8g.setFont(FONT_BIG); if (score >= 100) { u8g.print("A++"); } else if (score >= 90) { |