From abd2f514d016a88aeadbd16b3f76fc3e45d17498 Mon Sep 17 00:00:00 2001 From: Elena of Valhalla'' Grandi Date: Sat, 6 Apr 2013 13:32:28 +0200 Subject: Ardino sketch: randomize drift for a new arrow --- arduino_sketch/arcerino/arcerino.ino | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'arduino_sketch') 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 { -- cgit v1.2.3