This is the first version of a Fishing Mini-game. It uses a navigational switch as a button and a joystick, playing wav files from a SD card, and a uLCD screen to show the fishing game

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player

Revision:
0:5d811b6879d5
Child:
1:8dd8fafa7fc8
diff -r 000000000000 -r 5d811b6879d5 Fish.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Fish.h	Thu Mar 17 18:33:52 2016 +0000
@@ -0,0 +1,80 @@
+class Fish
+{
+    public:
+        Fish();
+        void reset();
+        int read();
+        int x();
+        int y();
+        void move(int n);
+        void movement();
+        bool failed();
+    private:
+        int x_pos; 
+        int y_pos;
+        int dir;
+        int size;
+        int time;
+        int clk;
+};
+
+Fish::Fish() {
+    x_pos = 64;
+    y_pos = 64;
+    if (rand() % 100 > 50) {
+        dir = 1;
+    } else {
+        dir = -1;
+    }
+    size = (rand() % 100) + 20;
+    time = ((rand() % 5) + 1)*5;
+    clk = 0;
+}
+
+void Fish::reset() {
+    x_pos = 64;
+    y_pos = 64;
+    if (rand() % 100 > 50) {
+        dir = 1;
+    } else {
+        dir = -1;
+    }
+    size = (rand() % 100) + 20;
+    time = ((rand() % 5) + 1)*5;
+    clk = 0;
+}
+
+int Fish::x() {
+    return x_pos;
+}
+
+int Fish::y() {
+    return y_pos;
+}
+
+void Fish::move(int n) {
+    x_pos = x_pos + n;
+}
+
+void Fish::movement() {
+    if(clk >= time) {
+        clk = 0;
+        time = ((rand() % 5) + 1)*5;
+        dir = dir * -1;
+    } else {
+        if (clk < (size/15)) {
+            move(dir * clk);
+        } else {
+            move(dir * (size/15));
+        }
+        clk++;
+    }
+}
+
+bool Fish::failed() {
+    if(x_pos < 30 || x_pos > 98) {
+        return false;
+    } else {
+        return true;
+    }
+}
\ No newline at end of file