aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arduino_sketch/arcerino/arcerino.ino82
1 files changed, 56 insertions, 26 deletions
diff --git a/arduino_sketch/arcerino/arcerino.ino b/arduino_sketch/arcerino/arcerino.ino
index 141af70..ba1a6fa 100644
--- a/arduino_sketch/arcerino/arcerino.ino
+++ b/arduino_sketch/arcerino/arcerino.ino
@@ -18,46 +18,43 @@ char drift_x,drift_y=0;
char score=0;
-void setup() {
- nunchuk_init();
- u8g.setColorIndex(1);
- u8g.setContrast(192);
- // TODO: draw startup screen
- delay(1000);
+void draw_game() {
+ u8g.setFont(u8g_font_5x7);
+ u8g.setPrintPos(0,8);
+ u8g.print(score,DEC);
+ u8g.drawCircle(42,24,24);
+ u8g.drawCircle(42,24,16);
+ u8g.drawCircle(42,24,8);
+ u8g.drawVLine(x+LCD_0X,y-4+LCD_0Y,9);
+ u8g.drawHLine(x-4+LCD_0X,y+LCD_0Y,9);
}
-void draw() {
+void draw_score() {
u8g.setFont(u8g_font_5x7);
u8g.setPrintPos(0,8);
u8g.print(score,DEC);
u8g.drawCircle(42,24,24);
u8g.drawCircle(42,24,16);
u8g.drawCircle(42,24,8);
+ u8g.drawDisc(x+LCD_0X,y+LCD_0Y,3);
+}
+
+void draw_title() {
+ u8g.setFont(u8g_font_9x15);
+ u8g.setPrintPos(0,24);
+ u8g.print("Arcerino");
+ u8g.setFont(u8g_font_5x7);
+ u8g.setPrintPos(30,46);
+ u8g.print("Loading...");
+}
+
+void update_position() {
drift_x = drift_x + random(-1,2);
drift_x = constrain(drift_x,-LCD_MAX,LCD_MAX);
drift_y = drift_y + random(-1,2);
drift_y = constrain(drift_y,-LCD_MAX,LCD_MAX);
x = map(nunchuk_cjoy_x(),-JOY_MAX,JOY_MAX,-LCD_MAX,LCD_MAX) + drift_x;
y = map(nunchuk_cjoy_y(),-JOY_MAX,JOY_MAX,LCD_MAX,-LCD_MAX) + drift_y;
- u8g.drawVLine(x+LCD_0X,y-4+LCD_0Y,9);
- u8g.drawHLine(x-4+LCD_0X,y+LCD_0Y,9);
-}
-
-void loop() {
- nunchuk_get_data();
-
- u8g.firstPage();
- do {
- draw();
- } while(u8g.nextPage());
-
- if (nunchuk_zbutton()) {
- score = score + get_score();
- // TODO: draw score screen
- delay(3000);
- } else {
- delay(100);
- }
}
char get_score() {
@@ -77,3 +74,36 @@ char get_score() {
return 0;
}
}
+
+void setup() {
+ nunchuk_init();
+ u8g.setColorIndex(1);
+ u8g.setContrast(192);
+ nunchuk_get_data();
+ u8g.firstPage();
+ do {
+ draw_title();
+ } while(u8g.nextPage());
+ delay(4000);
+}
+
+void loop() {
+ nunchuk_get_data();
+
+ if (nunchuk_zbutton()) {
+ score = score + get_score();
+ u8g.firstPage();
+ do {
+ draw_score();
+ } while(u8g.nextPage());
+ delay(3000);
+ } else {
+ update_position();
+ u8g.firstPage();
+ do {
+ draw_game();
+ } while(u8g.nextPage());
+ delay(100);
+ }
+}
+