Whack a Mole game! Features: - LCD graphics display - Touch pad input - Speaker effects through a class D audio amplifier\ - A high score page maintained by the SD card file system - Analog noise used to seed random numbers

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed

Fork of MPR121_Demo by jim hamblen

Files at this revision

API Documentation at this revision

Comitter:
tpettet3
Date:
Mon Mar 14 21:16:42 2016 +0000
Parent:
10:a31802412ab6
Commit message:
Public Release 1.0

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r a31802412ab6 -r 9c2e3efd7cda main.cpp
--- a/main.cpp	Mon Mar 14 19:04:38 2016 +0000
+++ b/main.cpp	Mon Mar 14 21:16:42 2016 +0000
@@ -147,6 +147,38 @@
 int rmole=18;//radius mole
 int mole= 0xD3D3D3;//mole color like gray
 
+
+//mole face
+int lx114=10;//14x
+int lx214=17;
+int rx114=25;
+int rx214=32;
+int lx125=53;//25x
+int lx225=60;
+int rx125=68;
+int rx225=75;
+int lx136=97;//36x
+int lx236=103;
+int rx136=111;
+int rx236=118;
+
+int eyey123=10;//123y
+int eyey456=56;//456y
+int eyecolor=0x0000;
+int nosecolor=0x0000;
+int whisker=0x0000;
+int rnose=2;
+
+int wb123=27;//pos123
+int wm123=21;
+int wt123=15;
+int wb456=70;//pos456
+int wm456=64;
+int wt456=58;
+
+
+
+
 lcd.circle(col1, row1 , r, out);// draws 6 circles to the lcd screen to show where the moles will appear
 lcd.circle(col1, row2 , r, out);
 lcd.circle(col2, row1 , r, out);
@@ -244,6 +276,15 @@
             lcd.filled_circle(col3, row1 , rmole, fill);
             lcd.filled_circle(col3, row2 , rmole, fill);
             lcd.filled_circle(col1, row1 , rmole, mole);
+            //face1
+            lcd.line(lx114, eyey123 , lx214, eyey123, eyecolor);//left eye
+            lcd.line(rx114, eyey123 , rx214, eyey123, eyecolor);//right eye
+            lcd.line(lx114, wb123 , rx214, wt123, whisker);//bottom
+            lcd.line(lx114, wm123 , rx214, wm123, whisker);//middle
+            lcd.line(lx114, wt123 , rx214, wb123, whisker);//top
+            lcd.filled_circle(col1, row1 , rnose, nosecolor);//nose
+
+            
             break;
             case 1:
             //POS_MUTEX.lock();
@@ -262,6 +303,13 @@
             lcd.filled_circle(col3, row1 , rmole, fill);
             lcd.filled_circle(col3, row2 , rmole, fill);
             lcd.filled_circle(col2, row1 , rmole, mole);
+            //face2
+            lcd.line(lx125, eyey123 , lx225, eyey123, eyecolor);//left eye
+            lcd.line(rx125, eyey123 , rx225, eyey123, eyecolor);//right eye
+            lcd.line(lx125, wb123 , rx225, wt123, whisker);//bottom
+            lcd.line(lx125, wm123 , rx225, wm123, whisker);//middle
+            lcd.line(lx125, wt123 , rx225, wb123, whisker);//top
+            lcd.filled_circle(col2, row1 , rnose, nosecolor);//nose
             break;
             case 2:
             //POS_MUTEX.lock();
@@ -280,6 +328,14 @@
             lcd.filled_circle(col3, row1 , rmole, fill);
             lcd.filled_circle(col3, row2 , rmole, fill);
             lcd.filled_circle(col3, row1 , rmole, mole);
+            
+            //face3
+            lcd.line(lx136, eyey123 , lx236, eyey123, eyecolor);//left eye
+            lcd.line(rx136, eyey123 , rx236, eyey123, eyecolor);//right eye
+            lcd.line(lx136, wb123 , rx236, wt123, whisker);//bottom
+            lcd.line(lx136, wm123 , rx236, wm123, whisker);//middle
+            lcd.line(lx136, wt123 , rx236, wb123, whisker);//top
+            lcd.filled_circle(col3, row1 , rnose, nosecolor);//nose
             break;
             case 3:
             //POS_MUTEX.lock();
@@ -298,6 +354,15 @@
             lcd.filled_circle(col3, row1 , rmole, fill);
             lcd.filled_circle(col3, row2 , rmole, fill);
             lcd.filled_circle(col1, row2 , rmole, mole);
+            
+            //face4
+            lcd.line(lx114, eyey456 , lx214, eyey456, eyecolor);//left eye
+            lcd.line(rx114, eyey456 , rx214, eyey456, eyecolor);//right eye
+            lcd.line(lx114, wb456 , rx214, wt456, whisker);//bottom
+            lcd.line(lx114, wm456 , rx214, wm456, whisker);//middle
+            lcd.line(lx114, wt456 , rx214, wb456, whisker);//top
+            lcd.filled_circle(col1, row2 , rnose, nosecolor);//nose
+            
             break;
             case 4:
             //POS_MUTEX.lock();
@@ -316,6 +381,14 @@
             lcd.filled_circle(col3, row1 , rmole, fill);
             lcd.filled_circle(col3, row2 , rmole, fill);
             lcd.filled_circle(col2, row2 , rmole, mole);
+            //face5
+             lcd.line(lx125, eyey456 , lx225, eyey456, eyecolor);//left eye
+            lcd.line(rx125, eyey456 , rx225, eyey456, eyecolor);//right eye
+            lcd.line(lx125, wb456 , rx225, wt456, whisker);//bottom
+            lcd.line(lx125, wm456 , rx225, wm456, whisker);//middle
+            lcd.line(lx125, wt456 , rx225, wb456, whisker);//top
+            lcd.filled_circle(col2, row2 , rnose, nosecolor);//nose
+            
             break;
             case 5:
             //POS_MUTEX.lock();
@@ -334,7 +407,15 @@
             lcd.filled_circle(col2, row2 , rmole, fill);
             lcd.filled_circle(col3, row1 , rmole, fill);
             lcd.filled_circle(col3, row2 , rmole, fill);
-            lcd.filled_circle(col2, row2 , rmole, mole);
+            lcd.filled_circle(col3, row2 , rmole, mole);
+            //face6
+             lcd.line(lx136, eyey456 , lx236, eyey456, eyecolor);//left eye
+            lcd.line(rx136, eyey456 , rx236, eyey456, eyecolor);//right eye
+            lcd.line(lx136, wb456 , rx236, wt456, whisker);//bottom
+            lcd.line(lx136, wm456 , rx236, wm456, whisker);//middle
+            lcd.line(lx136, wt456 , rx236, wb456, whisker);//top
+            lcd.filled_circle(col3, row2 , rnose, nosecolor);//nose
+            
             break;
             case 6:
             //POS_MUTEX.lock();
@@ -354,6 +435,21 @@
             lcd.filled_circle(col3, row2 , rmole, fill);
             lcd.filled_circle(col2, row1 , rmole, mole);
             lcd.filled_circle(col3, row2 , rmole, mole);
+            
+            //face2
+            lcd.line(lx125, eyey123 , lx225, eyey123, eyecolor);//left eye
+            lcd.line(rx125, eyey123 , rx225, eyey123, eyecolor);//right eye
+            lcd.line(lx125, wb123 , rx225, wt123, whisker);//bottom
+            lcd.line(lx125, wm123 , rx225, wm123, whisker);//middle
+            lcd.line(lx125, wt123 , rx225, wb123, whisker);//top
+            lcd.filled_circle(col2, row1 , rnose, nosecolor);//nose
+            //face6
+            lcd.line(lx136, eyey456 , lx236, eyey456, eyecolor);//left eye
+            lcd.line(rx136, eyey456 , rx236, eyey456, eyecolor);//right eye
+            lcd.line(lx136, wb456 , rx236, wt456, whisker);//bottom
+            lcd.line(lx136, wm456 , rx236, wm456, whisker);//middle
+            lcd.line(lx136, wt456 , rx236, wb456, whisker);//top
+            lcd.filled_circle(col3, row2 , rnose, nosecolor);//nose
             break;
             case 7:
             //POS_MUTEX.lock();
@@ -373,6 +469,21 @@
             lcd.filled_circle(col3, row2 , rmole, fill);
             lcd.filled_circle(col1, row1 , rmole, mole);
             lcd.filled_circle(col3, row1 , rmole, mole);
+            
+            //face1
+            lcd.line(lx114, eyey123 , lx214, eyey123, eyecolor);//left eye
+            lcd.line(rx114, eyey123 , rx214, eyey123, eyecolor);//right eye
+            lcd.line(lx114, wb123 , rx214, wt123, whisker);//bottom
+            lcd.line(lx114, wm123 , rx214, wm123, whisker);//middle
+            lcd.line(lx114, wt123 , rx214, wb123, whisker);//top
+            lcd.filled_circle(col1, row1 , rnose, nosecolor);//nose
+            //face3
+            lcd.line(lx136, eyey123 , lx236, eyey123, eyecolor);//left eye
+            lcd.line(rx136, eyey123 , rx236, eyey123, eyecolor);//right eye
+            lcd.line(lx136, wb123 , rx236, wt123, whisker);//bottom
+            lcd.line(lx136, wm123 , rx236, wm123, whisker);//middle
+            lcd.line(lx136, wt123 , rx236, wb123, whisker);//top
+            lcd.filled_circle(col3, row1 , rnose, nosecolor);//nose
             break;
             case 8:
             //POS_MUTEX.lock();
@@ -393,7 +504,21 @@
             lcd.filled_circle(col3, row2 , rmole, fill);
             lcd.filled_circle(col2, row1 , rmole, mole);
             lcd.filled_circle(col1, row2 , rmole, mole);
-            lcd.filled_circle(col3, row2 , rmole, mole);
+            //face2
+            lcd.line(lx125, eyey123 , lx225, eyey123, eyecolor);//left eye
+            lcd.line(rx125, eyey123 , rx225, eyey123, eyecolor);//right eye
+            lcd.line(lx125, wb123 , rx225, wt123, whisker);//bottom
+            lcd.line(lx125, wm123 , rx225, wm123, whisker);//middle
+            lcd.line(lx125, wt123 , rx225, wb123, whisker);//top
+            lcd.filled_circle(col2, row1 , rnose, nosecolor);//nose
+            //face4
+            lcd.line(lx114, eyey456 , lx214, eyey456, eyecolor);//left eye
+            lcd.line(rx114, eyey456 , rx214, eyey456, eyecolor);//right eye
+            lcd.line(lx114, wb456 , rx214, wt456, whisker);//bottom
+            lcd.line(lx114, wm456 , rx214, wm456, whisker);//middle
+            lcd.line(lx114, wt456 , rx214, wb456, whisker);//top
+            lcd.filled_circle(col1, row2 , rnose, nosecolor);//nose
+            
             break;
             case 9:
             //POS_MUTEX.lock();
@@ -414,6 +539,27 @@
             lcd.filled_circle(col3, row1 , rmole, mole);
             lcd.filled_circle(col1, row2 , rmole, mole);
             lcd.filled_circle(col3, row2 , rmole, mole);
+            //face3
+            lcd.line(lx136, eyey123 , lx236, eyey123, eyecolor);//left eye
+            lcd.line(rx136, eyey123 , rx236, eyey123, eyecolor);//right eye
+            lcd.line(lx136, wb123 , rx236, wt123, whisker);//bottom
+            lcd.line(lx136, wm123 , rx236, wm123, whisker);//middle
+            lcd.line(lx136, wt123 , rx236, wb123, whisker);//top
+            lcd.filled_circle(col3, row1 , rnose, nosecolor);//nose
+            //face4
+            lcd.line(lx114, eyey456 , lx214, eyey456, eyecolor);//left eye
+            lcd.line(rx114, eyey456 , rx214, eyey456, eyecolor);//right eye
+            lcd.line(lx114, wb456 , rx214, wt456, whisker);//bottom
+            lcd.line(lx114, wm456 , rx214, wm456, whisker);//middle
+            lcd.line(lx114, wt456 , rx214, wb456, whisker);//top
+            lcd.filled_circle(col1, row2 , rnose, nosecolor);//nose
+            //face6
+            lcd.line(lx136, eyey456 , lx236, eyey456, eyecolor);//left eye
+            lcd.line(rx136, eyey456 , rx236, eyey456, eyecolor);//right eye
+            lcd.line(lx136, wb456 , rx236, wt456, whisker);//bottom
+            lcd.line(lx136, wm456 , rx236, wm456, whisker);//middle
+            lcd.line(lx136, wt456 , rx236, wb456, whisker);//top
+            lcd.filled_circle(col3, row2 , rnose, nosecolor);//nose
             break;
             case 10:
             //POS_MUTEX.lock();
@@ -433,6 +579,20 @@
             lcd.filled_circle(col3, row2 , rmole, fill);
             lcd.filled_circle(col1, row1 , rmole, mole);
             lcd.filled_circle(col3, row2 , rmole, mole);
+            //face1
+            lcd.line(lx114, eyey123 , lx214, eyey123, eyecolor);//left eye
+            lcd.line(rx114, eyey123 , rx214, eyey123, eyecolor);//right eye
+            lcd.line(lx114, wb123 , rx214, wt123, whisker);//bottom
+            lcd.line(lx114, wm123 , rx214, wm123, whisker);//middle
+            lcd.line(lx114, wt123 , rx214, wb123, whisker);//top
+            lcd.filled_circle(col1, row1 , rnose, nosecolor);//nose
+            //face6
+            lcd.line(lx136, eyey456 , lx236, eyey456, eyecolor);//left eye
+            lcd.line(rx136, eyey456 , rx236, eyey456, eyecolor);//right eye
+            lcd.line(lx136, wb456 , rx236, wt456, whisker);//bottom
+            lcd.line(lx136, wm456 , rx236, wm456, whisker);//middle
+            lcd.line(lx136, wt456 , rx236, wb456, whisker);//top
+            lcd.filled_circle(col3, row2 , rnose, nosecolor);//nose
             break;
             case 11:
             //POS_MUTEX.lock();
@@ -454,6 +614,35 @@
             lcd.filled_circle(col3, row1 , rmole, mole);
             lcd.filled_circle(col2, row2 , rmole, mole);
             lcd.filled_circle(col3, row2 , rmole, mole);
+            //face2
+            lcd.line(lx125, eyey123 , lx225, eyey123, eyecolor);//left eye
+            lcd.line(rx125, eyey123 , rx225, eyey123, eyecolor);//right eye
+            lcd.line(lx125, wb123 , rx225, wt123, whisker);//bottom
+            lcd.line(lx125, wm123 , rx225, wm123, whisker);//middle
+            lcd.line(lx125, wt123 , rx225, wb123, whisker);//top
+            lcd.filled_circle(col2, row1 , rnose, nosecolor);//nose
+            //face3
+            lcd.line(lx136, eyey123 , lx236, eyey123, eyecolor);//left eye
+            lcd.line(rx136, eyey123 , rx236, eyey123, eyecolor);//right eye
+            lcd.line(lx136, wb123 , rx236, wt123, whisker);//bottom
+            lcd.line(lx136, wm123 , rx236, wm123, whisker);//middle
+            lcd.line(lx136, wt123 , rx236, wb123, whisker);//top
+            lcd.filled_circle(col3, row1 , rnose, nosecolor);//nose
+            //face5
+            lcd.line(lx125, eyey456 , lx225, eyey456, eyecolor);//left eye
+            lcd.line(rx125, eyey456 , rx225, eyey456, eyecolor);//right eye
+            lcd.line(lx125, wb456 , rx225, wt456, whisker);//bottom
+            lcd.line(lx125, wm456 , rx225, wm456, whisker);//middle
+            lcd.line(lx125, wt456 , rx225, wb456, whisker);//top
+            lcd.filled_circle(col2, row2 , rnose, nosecolor);//nose
+            //face6
+             lcd.line(lx136, eyey456 , lx236, eyey456, eyecolor);//left eye
+            lcd.line(rx136, eyey456 , rx236, eyey456, eyecolor);//right eye
+            lcd.line(lx136, wb456 , rx236, wt456, whisker);//bottom
+            lcd.line(lx136, wm456 , rx236, wm456, whisker);//middle
+            lcd.line(lx136, wt456 , rx236, wb456, whisker);//top
+            lcd.filled_circle(col3, row2 , rnose, nosecolor);//nose
+            
             break;
             case 12:
             //POS_MUTEX.lock();
@@ -473,6 +662,21 @@
             lcd.filled_circle(col3, row2 , rmole, fill);
             lcd.filled_circle(col3, row1 , rmole, mole);
             lcd.filled_circle(col2, row2 , rmole, mole);
+            
+            //face3
+            lcd.line(lx136, eyey123 , lx236, eyey123, eyecolor);//left eye
+            lcd.line(rx136, eyey123 , rx236, eyey123, eyecolor);//right eye
+            lcd.line(lx136, wb123 , rx236, wt123, whisker);//bottom
+            lcd.line(lx136, wm123 , rx236, wm123, whisker);//middle
+            lcd.line(lx136, wt123 , rx236, wb123, whisker);//top
+            lcd.filled_circle(col3, row1 , rnose, nosecolor);//nose
+            //face5
+            lcd.line(lx125, eyey456 , lx225, eyey456, eyecolor);//left eye
+            lcd.line(rx125, eyey456 , rx225, eyey456, eyecolor);//right eye
+            lcd.line(lx125, wb456 , rx225, wt456, whisker);//bottom
+            lcd.line(lx125, wm456 , rx225, wm456, whisker);//middle
+            lcd.line(lx125, wt456 , rx225, wb456, whisker);//top
+            lcd.filled_circle(col2, row2 , rnose, nosecolor);//nose
             break;
             case 13:
             //POS_MUTEX.lock();
@@ -493,6 +697,28 @@
             lcd.filled_circle(col1, row1 , rmole, mole);
             lcd.filled_circle(col1, row2 , rmole, mole);
             lcd.filled_circle(col2, row2 , rmole, mole);
+            //face1
+            lcd.line(lx114, eyey123 , lx214, eyey123, eyecolor);//left eye
+            lcd.line(rx114, eyey123 , rx214, eyey123, eyecolor);//right eye
+            lcd.line(lx114, wb123 , rx214, wt123, whisker);//bottom
+            lcd.line(lx114, wm123 , rx214, wm123, whisker);//middle
+            lcd.line(lx114, wt123 , rx214, wb123, whisker);//top
+            lcd.filled_circle(col1, row1 , rnose, nosecolor);//nose
+
+            //face4
+             lcd.line(lx114, eyey456 , lx214, eyey456, eyecolor);//left eye
+            lcd.line(rx114, eyey456 , rx214, eyey456, eyecolor);//right eye
+            lcd.line(lx114, wb456 , rx214, wt456, whisker);//bottom
+            lcd.line(lx114, wm456 , rx214, wm456, whisker);//middle
+            lcd.line(lx114, wt456 , rx214, wb456, whisker);//top
+            lcd.filled_circle(col1, row2 , rnose, nosecolor);//nose
+            //face5
+            lcd.line(lx125, eyey456 , lx225, eyey456, eyecolor);//left eye
+            lcd.line(rx125, eyey456 , rx225, eyey456, eyecolor);//right eye
+            lcd.line(lx125, wb456 , rx225, wt456, whisker);//bottom
+            lcd.line(lx125, wm456 , rx225, wm456, whisker);//middle
+            lcd.line(lx125, wt456 , rx225, wb456, whisker);//top
+            lcd.filled_circle(col2, row2 , rnose, nosecolor);//nose
             break;
             case 14:
             //POS_MUTEX.lock();
@@ -513,6 +739,21 @@
             lcd.filled_circle(col3, row2 , rmole, fill);
             lcd.filled_circle(col2, row1 , rmole, mole);
             lcd.filled_circle(col2, row2 , rmole, mole);
+            
+            //face2
+            lcd.line(lx125, eyey123 , lx225, eyey123, eyecolor);//left eye
+            lcd.line(rx125, eyey123 , rx225, eyey123, eyecolor);//right eye
+            lcd.line(lx125, wb123 , rx225, wt123, whisker);//bottom
+            lcd.line(lx125, wm123 , rx225, wm123, whisker);//middle
+            lcd.line(lx125, wt123 , rx225, wb123, whisker);//top
+            lcd.filled_circle(col2, row1 , rnose, nosecolor);//nose
+            //face5
+            lcd.line(lx125, eyey456 , lx225, eyey456, eyecolor);//left eye
+            lcd.line(rx125, eyey456 , rx225, eyey456, eyecolor);//right eye
+            lcd.line(lx125, wb456 , rx225, wt456, whisker);//bottom
+            lcd.line(lx125, wm456 , rx225, wm456, whisker);//middle
+            lcd.line(lx125, wt456 , rx225, wb456, whisker);//top
+            lcd.filled_circle(col2, row2 , rnose, nosecolor);//nose
             break;
             }
         wait(0.5);
@@ -520,6 +761,7 @@
         lcd.text_string("Score: ", 1, 15, FONT_7X8, GREEN);
         lcd.printf("%d",score);
         }
+        
     // clear the lcd screen
     lcd.cls();
     wait(0.5);