test avoid bulled game

Dependencies:   C12832_lcd LCD_fonts mbed mbed-rtos

Revision:
39:e8d6dd3c75c7
Parent:
38:63b99151e218
Child:
40:ec5c1b305b9a
--- a/Converter.cpp	Tue Dec 13 07:34:07 2016 +0000
+++ b/Converter.cpp	Tue Dec 13 11:55:17 2016 +0000
@@ -4,7 +4,25 @@
 #include "C12832_lcd.h" 
 #include <math.h>
 
-char* Converter::convert(int map[][LCD_X]){
+int pow(int x, int y){
+    int ans = 1;
+    for(int i = 0; i < y; i++){
+        ans *= x;
+    }
+    return ans;   
+}
+
+int binary(int bina){
+    int ans = 0;
+    for (int i = 0; bina>0 ; i++)
+    {
+        ans = ans+(bina%2)*pow(10,i);
+        bina = bina/2;
+    }
+    return ans;
+}
+
+Bitmap Converter::convert(int map[][LCD_X]){
     int len = LCD_Y*LCD_X/CHAR_SIZE;
     int count = 0;
     int tmp = 0;
@@ -12,12 +30,35 @@
     for(int i = 0; i < len; i++ ){
         char_map[i] = 0;
     }
+    
+//    for(int i = 0; i < LCD_X; i++){
+//        printf("line %d  height: ",i);
+//        for(int j = 0; j < LCD_Y; j++){
+//            printf("%d ",map[j][i]);
+//        }
+//        printf("\n");
+//    }
+//    printf("\n");
+    
+    
     for(int i = 0; i < LCD_Y; i++){
         for(int j = 0; j < LCD_X; j++){
             int index = (i*LCD_X + j)/CHAR_SIZE;
-            char_map[index] |= map[i][j] << ((CHAR_SIZE - 1) - index % CHAR_SIZE);   
+            //char_map[index] |= map[i][j] << ((CHAR_SIZE - 1) - index % CHAR_SIZE);
+            char_map[index] |= map[i][j] << ((CHAR_SIZE - 1) - (i*LCD_X + j) % CHAR_SIZE);   
         }
     }
+    
+//    for(int i = 0; i < len; i++){
+//        if(i % 16 == 0){
+//            printf("\n");
+//            printf("line %d  ", i);
+//        }
+//        printf("%d ", char_map[i]);
+//    }
+//    
+//     printf("\n");
+    
     //return char_map;
     Bitmap bitmap_converted = {
         LCD_X,
@@ -25,6 +66,8 @@
         LCD_X/CHAR_SIZE,
         char_map,
     };
-    //return bitmap_converted;
-    return char_map;
+    return bitmap_converted;
 }
+
+
+