N5110 Library for "Racing Cars" Game

Dependents:   RacingCarsGame

Fork of N5110 by Craig Evans

Revision:
19:cf23186a762f
Parent:
18:45c3696a1447
Child:
20:a6fc42d720c2
--- a/N5110.cpp	Sun Apr 26 21:33:53 2015 +0000
+++ b/N5110.cpp	Fri May 01 01:29:49 2015 +0000
@@ -329,6 +329,50 @@
     refresh();
 }
 
+void N5110:: clearCircle(int x0,int y0,int radius,int fill){
+        // from http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
+    int x = radius;
+    int y = 0;
+    int radiusError = 1-x;
+
+    while(x >= y) {
+
+        // if transparent, just draw outline
+        if (fill == 0) {
+            clearPixel( x + x0,  y + y0);
+            clearPixel(-x + x0,  y + y0);
+            clearPixel( y + x0,  x + y0);
+            clearPixel(-y + x0,  x + y0);
+            clearPixel(-y + x0, -x + y0);
+            clearPixel( y + x0, -x + y0);
+            clearPixel( x + x0, -y + y0);
+            clearPixel(-x + x0, -y + y0);
+        } else {  // drawing filled circle, so draw lines between points at same y value
+
+            int type = (fill==1) ? 1:0;  // black or white fill
+
+            drawLine(x+x0,y+y0,-x+x0,y+y0,type);
+            drawLine(y+x0,x+y0,-y+x0,x+y0,type);
+            drawLine(y+x0,-x+y0,-y+x0,-x+y0,type);
+            drawLine(x+x0,-y+y0,-x+x0,-y+y0,type);
+        }
+
+
+        y++;
+        if (radiusError<0) {
+            radiusError += 2 * y + 1;
+        } else {
+            x--;
+            radiusError += 2 * (y - x) + 1;
+        }
+    }
+
+    refresh();
+}
+    
+
+
+
 void N5110::drawLine(int x0,int y0,int x1,int y1,int type)
 {
     int y_range = y1-y0;  // calc range of y and x
@@ -381,11 +425,101 @@
 
 
 void N5110::gameInitial(){
+    
+    //road lanes
     drawLine(60,0,60,48,1);
     drawLine(60,16,84,16,1);
     drawLine(60,32,84,32,1);
     drawLine(20,0,20,48,2);
     drawLine(40,0,40,48,2);
+  
+    //heart shape
+    setPixel(62,9);
+    setPixel(62,10);
+    setPixel(62,11);
+    
+    setPixel(63,8);
+    setPixel(63,9);
+    setPixel(63,10);
+    setPixel(63,11);
+    setPixel(63,12);
+  
+    setPixel(64,7);
+    setPixel(64,8);
+    setPixel(64,9);
+    setPixel(64,10);
+    setPixel(64,11);
+    setPixel(64,12);
+    setPixel(64,13);
+    
+    setPixel(65,8);
+    setPixel(65,9);
+    setPixel(65,10);
+    setPixel(65,11);
+    setPixel(65,12);
+    setPixel(65,13);
+    setPixel(65,14);
+    
+    setPixel(66,9);
+    setPixel(66,10);
+    setPixel(66,11);
+    setPixel(66,12);
+    setPixel(66,13);
+    setPixel(66,14);
+    setPixel(66,15);
+    
+    setPixel(67,8);
+    setPixel(67,9);
+    setPixel(67,10);
+    setPixel(67,11);
+    setPixel(67,12);
+    setPixel(67,13);
+    setPixel(67,14);
+    
+    setPixel(68,7);
+    setPixel(68,8);
+    setPixel(68,9);
+    setPixel(68,10);
+    setPixel(68,11);
+    setPixel(68,12);
+    setPixel(68,13);
+    
+    setPixel(69,8);
+    setPixel(69,9);
+    setPixel(69,10);
+    setPixel(69,11);
+    setPixel(69,12);
+  
+    setPixel(70,9);
+    setPixel(70,10);
+    setPixel(70,11);
+    
+    
+    //print Round Indicator
+    printChar('R',62,3);
+    printChar(':',68,3);
+    
+    
+    //set the Coin Shape
+    drawCircle(66,43,4,0);
+    
+    setPixel(66,41);
+    setPixel(66,44);
+    
+    setPixel(67,41);
+    setPixel(67,44);
+    
+    setPixel(65,42);
+    setPixel(65,43);
+    
+    
+    
+   
+    
+
+    
+    
+    
     }