test avoid bulled game

Dependencies:   C12832_lcd LCD_fonts mbed mbed-rtos

Files at this revision

API Documentation at this revision

Comitter:
th_mbed
Date:
Mon Dec 12 12:47:07 2016 +0000
Parent:
35:b767ad058a8b
Child:
38:63b99151e218
Commit message:
fix some bugs

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:00:44 2016 +0000
+++ b/Converter.cpp	Mon Dec 12 12:47:07 2016 +0000
@@ -2,21 +2,22 @@
 #include "models.h"
 #include "point.h"
 #include "C12832_lcd.h" 
-#define CHAR_SIZE 8
+#include <math.h>
 
 Bitmap Converter::convert(int map[][LCD_X]){
     int len = LCD_Y*LCD_X/CHAR_SIZE;
+    int count = 0;
+    int tmp = 0;
     char char_map[len];
     for(int i = 0; i < len; i++ ){
         char_map[i] = 0;
     }
     for(int i = 0; i < LCD_Y; i++){
         for(int j = 0; j < LCD_X; j++){
-            char_map[(i*LCD_X+j)/CHAR_SIZE] |= map[i][j] << ((CHAR_SIZE - 1) - i % CHAR_SIZE);
-        }
+            int index = (i*LCD_X + j)/CHAR_SIZE;
+            char_map[index] |= map[i][j] << ((CHAR_SIZE - 1) - index % CHAR_SIZE);        }
     }
-    return char_map;
-    /*
+    //return char_map;
     Bitmap bitmap_converted = {
         LCD_X,
         LCD_Y,
@@ -24,5 +25,4 @@
         char_map,
     };
     return bitmap_converted;
-    */
 }
--- a/convert.h	Mon Dec 12 12:00:44 2016 +0000
+++ b/convert.h	Mon Dec 12 12:47:07 2016 +0000
@@ -2,6 +2,7 @@
 #define CONVERT_H
 #include "C12832_lcd.h" 
 #include "models.h"
+#define CHAR_SIZE 8
 class Converter
 {
 public:
--- a/main.cpp	Mon Dec 12 12:00:44 2016 +0000
+++ b/main.cpp	Mon Dec 12 12:47:07 2016 +0000
@@ -38,10 +38,10 @@
 
 void make_wall(){
     wall_height = stage.getStage();
-    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] = white_board[i][j] ^ 1;
+    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;
             }
         }
     }
@@ -103,7 +103,7 @@
     lcd.setmode(XOR);
     int gameOver = 0;
     srand((int)(aIn * 100));
-    Converter converter();
+    Converter converter;
 //    Bitmap picture;
     
     while(true){
@@ -115,7 +115,7 @@
             p_bullet = b->update();
         }
         //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);
+        //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);
         update_mtx.unlock();