test avoid bulled game
Dependencies: C12832_lcd LCD_fonts mbed mbed-rtos
Revision 30:f26dcbaa946d, committed 2016-12-12
- Comitter:
- kaku_jyoko
- Date:
- Mon Dec 12 11:17:22 2016 +0000
- Parent:
- 27:afdaee781efa
- Parent:
- 29:7784b098ef1d
- Child:
- 31:17b4ee41bdc5
- Child:
- 32:abb3086c210d
- Commit message:
- change
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/KakuGraphicBuilder.cpp Mon Dec 12 11:17:22 2016 +0000 @@ -0,0 +1,49 @@ +#include "kaku_integrate.h" +#include "models.h" +#include "graphics.h" + +char map = {0x00}; + + +KakuGraphicBuilder::KakuGraphicBuilder() +{ + Bitmap b = { + LCD_X, + LCD_Y, + LCD_X / 8, + map, + }; + bitmap_all = b; + reset_white_board(); +} + +Bitmap KakuGraphicBuilder::integrateBitmap(point pe, point bu, point st[]) +{ + Bitmap b; + return b; + +} + +void KakuGraphicBuilder::convolution(point p, int width, int height) +{ + +} + +void KakuGraphicBuilder::reset_white_board() +{ + for(int i = 0; i < LCD_Y; i++){ + for (int j = 0; j < LCD_X; j++){ + white_board[i][j] = 0; + } + } +} + +void intToBitmap(){ + for(int i = 0; i < LCD_Y ; i++){ + for (int j = 1; j <= LCD_X / 8; j++){ + + } + } +} + +
--- a/graphics.h Mon Dec 12 11:11:01 2016 +0000 +++ b/graphics.h Mon Dec 12 11:17:22 2016 +0000 @@ -11,7 +11,7 @@ 0x50 }; -Bitmap bitmPlayer = { +static Bitmap bitmPlayer = { 6, // XSize 6, // YSize 1, // Bytes in Line @@ -27,7 +27,7 @@ 0x50 }; -Bitmap bitmPlayerB = { +static Bitmap bitmPlayerB = { 6, // XSize 6, // YSize 1, // Bytes in Line @@ -42,7 +42,7 @@ 0x00 }; -Bitmap bitmBullet_graphics = { +static Bitmap bitmBullet_graphics = { 5, 5, 1,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kaku_integrate.h Mon Dec 12 11:17:22 2016 +0000 @@ -0,0 +1,29 @@ +#ifndef kaku_integrate_H +#define kaku_integrate_H +#include "C12832_lcd.h" +#include "models.h" + + +class KakuGraphicBuilder +{ +private: + point pe; + point bu; + point st[]; + char map[(LCD_X / 8) * LCD_Y]; + Bitmap bitmap_all; + + void convolution(point p, int width, int heigth); + + void intToBitmap(); + + int white_board[LCD_Y][LCD_X]; + + void reset_white_board(); + +public: + Bitmap integrateBitmap(point pe, point bu, point st[]); + KakuGraphicBuilder(); +}; + +#endif \ No newline at end of file
--- a/main.cpp Mon Dec 12 11:11:01 2016 +0000 +++ b/main.cpp Mon Dec 12 11:17:22 2016 +0000 @@ -6,21 +6,46 @@ #include "models.h" #include "rtos.h" #include "point.h" +#include "stdlib.h" C12832_LCD lcd; // down: p12, left: p13, center: p14, up: p15, right: p16 InterruptIn button(p14); +AnalogIn aIn(p20); DigitalOut led1(LED1); Mutex jump_mtx; Mutex update_mtx; int jump_flag = 0; Person h; +Stage stage; Serial pc(USBTX, USBRX); // tx, rx Bullet* b = NULL; Timer t; +char picture[(LCD_X / 8 + 1) * LCD_Y]; +int white_board[LCD_Y][LCD_X]; +int* wall_height; +void reset_white_board() +{ + for(int i = 0; i < LCD_Y; i++){ + for (int j = 0; j < LCD_X; j++){ + white_board[i][j] = 0; + } + } +} + +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; + } + } + } +} void a(){ h.jump(); @@ -51,18 +76,37 @@ } } +int corrision_judge(point p_person, point p_bullet){ + 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); + if((p_person.x + 2 >= p_bullet.x) && (p_person.x + 2 <= p_bullet.x + 5)){ + printf("aaaaa"); + if((p_person.y + 2 >= p_bullet.y + 1) && (p_person.y + 2 <= p_bullet.y + 4)){ + printf("gameover\n"); + } + } + return 0; +} + int main(){ point p_person, p_bullet; printf("hello\n"); Thread jump_th(jump_receive); Thread bullet_th(bullet_receive); + lcd.setmode(XOR); + int gameOver = 0; + srand((int)(aIn * 100)); while(true){ update_mtx.lock(); + reset_white_board(); + make_wall(); p_person = h.update(1); if(b != NULL){ p_bullet = b->update(); } - //printf("x: %d, y: %d", p_bullet.x,p_bullet.y); + //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); update_mtx.unlock(); lcd.cls(); lcd.print_bm(bitmPlayer,p_person.x,p_person.y);