aboutsummaryrefslogtreecommitdiff
path: root/arduino_sketch
diff options
context:
space:
mode:
authorElena of Valhalla'' Grandi <valhalla.trueelena.org>2013-04-06 13:32:28 +0200
committerElena of Valhalla'' Grandi <valhalla.trueelena.org>2013-04-06 13:32:28 +0200
commitabd2f514d016a88aeadbd16b3f76fc3e45d17498 (patch)
tree6cd3fcc3b9f2f23161b8a25cbf07b31986d80ec0 /arduino_sketch
parent668f40084c176633bd4e430e504c5632b0442774 (diff)
Ardino sketch: randomize drift for a new arrow
Diffstat (limited to 'arduino_sketch')
-rw-r--r--arduino_sketch/arcerino/arcerino.ino18
1 files changed, 16 insertions, 2 deletions
diff --git a/arduino_sketch/arcerino/arcerino.ino b/arduino_sketch/arcerino/arcerino.ino
index b2b9c38..7b9662e 100644
--- a/arduino_sketch/arcerino/arcerino.ino
+++ b/arduino_sketch/arcerino/arcerino.ino
@@ -114,6 +114,17 @@ char get_score() {
}
}
+void new_arrow() {
+ arrows = arrows--;
+ drift_x = random(-LCD_MAX/2,LCD_MAX/2) + random(-LCD_MAX/2,LCD_MAX/2);
+ drift_y = random(-LCD_MAX/2,LCD_MAX/2) + random(-LCD_MAX/2,LCD_MAX/2);
+}
+
+void new_round() {
+ arrows = 10;
+ score = 0;
+}
+
void setup() {
nunchuk_init();
u8g.setColorIndex(1);
@@ -124,6 +135,8 @@ void setup() {
draw_title();
} while(u8g.nextPage());
delay(4000);
+ new_arrow();
+ new_round();
}
void loop() {
@@ -132,7 +145,7 @@ void loop() {
if (play) {
if (nunchuk_zbutton()) {
score = score + get_score();
- arrows = arrows--;
+ new_arrow();
u8g.firstPage();
do {
draw_score();
@@ -140,7 +153,6 @@ void loop() {
delay(3000);
if ( arrows <= 0 ) {
play = false;
- arrows = 10;
}
} else {
update_position();
@@ -152,7 +164,9 @@ void loop() {
}
} else {
if (nunchuk_zbutton()) {
+ new_round();
play=true;
+ delay(200);
} else {
u8g.firstPage();
do {