test avoid bulled game

Dependencies:   C12832_lcd LCD_fonts mbed mbed-rtos

Files at this revision

API Documentation at this revision

Comitter:
kaku_jyoko
Date:
Tue Dec 13 07:34:07 2016 +0000
Parent:
36:b88fa8ff0be9
Parent:
37:f5d98f22b6bd
Child:
39:e8d6dd3c75c7
Commit message:
change

Changed in this revision

Converter.cpp Show annotated file Show diff for this revision Revisions of this file
convert.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Converter.cpp	Mon Dec 12 12:47:07 2016 +0000
+++ b/Converter.cpp	Tue Dec 13 07:34:07 2016 +0000
@@ -4,7 +4,7 @@
 #include "C12832_lcd.h" 
 #include <math.h>
 
-Bitmap Converter::convert(int map[][LCD_X]){
+char* Converter::convert(int map[][LCD_X]){
     int len = LCD_Y*LCD_X/CHAR_SIZE;
     int count = 0;
     int tmp = 0;
@@ -15,7 +15,8 @@
     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);   
+        }
     }
     //return char_map;
     Bitmap bitmap_converted = {
@@ -24,5 +25,6 @@
         LCD_X/CHAR_SIZE,
         char_map,
     };
-    return bitmap_converted;
+    //return bitmap_converted;
+    return char_map;
 }
--- a/convert.h	Mon Dec 12 12:47:07 2016 +0000
+++ b/convert.h	Tue Dec 13 07:34:07 2016 +0000
@@ -6,7 +6,7 @@
 class Converter
 {
 public:
-    Bitmap convert(int map[][LCD_X]);
+    char* convert(int map[][LCD_X]);
 };
 
 #endif
\ No newline at end of file
--- a/main.cpp	Mon Dec 12 12:47:07 2016 +0000
+++ b/main.cpp	Tue Dec 13 07:34:07 2016 +0000
@@ -38,10 +38,10 @@
 
 void make_wall(){
     wall_height = stage.getStage();
-    for(int i = 0; i < LCD_X; i++){
-        for(int j = LCD_Y - 1; j >= 0; j--){
-            if(LCD_Y - 1 - wall_height[i] <= j){
-                white_board[j][i] = white_board[j][i] = 1;
+    for(int i = 0; i < LCD_Y; i++){
+        for(int j = 0; j < LCD_X ; j++){
+            if(wall_height[i] > (LCD_Y - 1 - j)){
+                white_board[i][j] = 1;
             }
         }
     }
@@ -103,7 +103,13 @@
     lcd.setmode(XOR);
     int gameOver = 0;
     srand((int)(aIn * 100));
+<<<<<<< local
     Converter converter;
+=======
+    Converter converter();
+    int len = LCD_Y*LCD_X/8;
+    char char_map[len];
+>>>>>>> other
 //    Bitmap picture;
     
     while(true){
@@ -117,10 +123,16 @@
         //printf("bullet  x: %d,  y: %d \n", p_bullet.x,p_bullet.y);
         //printf("person  x: %d,  y: %d \n", p_person.x,p_person.y);
         corrision_judge(p_person, p_bullet);
-        Bitmap picture = converter.convert(white_board);
+        Bitmap bitmap_converted = {
+             LCD_X,
+             LCD_Y,
+            LCD_X/8,
+            char_map,
+         };
         update_mtx.unlock();
         lcd.cls();
         lcd.print_bm(bitmPlayer,p_person.x,p_person.y);
+        lcd.print_bm(bitmap_converted,0,0);
         if(b != NULL){
             lcd.print_bm(bitmBullet_graphics, p_bullet.x, p_bullet.y);
         }
@@ -128,6 +140,7 @@
         wait(0.02);
         lcd.cls();
         lcd.print_bm(bitmPlayerB,p_person.x,p_person.y);
+        lcd.print_bm(bitmap_converted,0,0);
         if(b != NULL){
             lcd.print_bm(bitmBullet_graphics, p_bullet.x, p_bullet.y);
         }