test avoid bulled game
Dependencies: C12832_lcd LCD_fonts mbed mbed-rtos
Revision 6:e63641e13374, committed 2016-12-02
- Comitter:
- kaku_jyoko
- Date:
- Fri Dec 02 13:33:02 2016 +0000
- Parent:
- 5:651879f4f047
- Child:
- 7:defdc7cb4e0b
- Commit message:
- player jump
Changed in this revision
--- a/Person.cpp Fri Dec 02 09:37:23 2016 +0000 +++ b/Person.cpp Fri Dec 02 13:33:02 2016 +0000 @@ -14,11 +14,11 @@ return p; }else if(jump_time == MAX_JUMP_TIME){ //down - p.y -= 1; + p.y += 1; }else{ //up jump_time++; - p.y++; + p.y--; } return p; } @@ -31,7 +31,7 @@ point Person::jump(){ if(jump_count < MAX_JUMP_COUNT){ - p.y++; + p.y--; jump_time = 1; jump_count++; }
--- a/graphics.h Fri Dec 02 09:37:23 2016 +0000 +++ b/graphics.h Fri Dec 02 13:33:02 2016 +0000 @@ -2,7 +2,7 @@ #define graphics_H #include "C12832_lcd.h" -static char Person[] = { +static char Player[] = { 0x30, 0x70, 0x28, @@ -11,14 +11,14 @@ 0x50 }; -Bitmap bitmPerson = { +Bitmap bitmPlayer = { 6, // XSize 6, // YSize 1, // Bytes in Line - Person, // Pointer to picture data + Player, // Pointer to picture data }; -static char PersonB[] = { +static char PlayerB[] = { 0x30, 0x70, 0xA0, @@ -27,11 +27,11 @@ 0x50 }; -Bitmap bitmPersonB = { +Bitmap bitmPlayerB = { 6, // XSize 6, // YSize 1, // Bytes in Line - PersonB, // Pointer to picture data + PlayerB, // Pointer to picture data }; #endif \ No newline at end of file
--- a/main.cpp Fri Dec 02 09:37:23 2016 +0000 +++ b/main.cpp Fri Dec 02 13:33:02 2016 +0000 @@ -16,40 +16,24 @@ Mutex jump_mtx; Mutex update_mtx; int jump_flag = 0; - -//int main(){ -// lcd.cls(); -// lcd.set_font((unsigned char*) Arial_9); -// while(1){ -// lcd.print_bm(bitmPerson,2,32-6); -// lcd.copy_to_lcd(); -// wait(0.5); -// lcd.print_bm(bitmPersonB,2,32-6); -// lcd.copy_to_lcd(); -// wait(0.5); -// } -//} +Person h; void a(){ - jump_flag = !jump_flag; + h.jump(); } void receive(void const *argument){ while(true){ - if(button){ - jump_mtx.lock(); - button.rise(&a); - jump_mtx.unlock(); - printf("flag %d\n",jump_flag); - Thread::wait(0.1); - } + jump_mtx.lock(); + button.rise(&a); + jump_mtx.unlock(); + //Thread::wait(0.1); } } int main(){ - Person h(); point p; printf("hello\n"); Thread receive_th(receive); @@ -57,16 +41,15 @@ update_mtx.lock(); p = h.update(); update_mtx.unlock(); - lcd.print_bm(bitmPerson,p.x,p.y); + + //printf("x:%d y:%d\n", p.x,p.y); + lcd.cls(); + lcd.print_bm(bitmPlayer,p.x,p.y); lcd.copy_to_lcd(); - wait(0.5); - lcd.print_bm(bitmPersonB,p.x,p.y); + wait(0.02); + lcd.cls(); + lcd.print_bm(bitmPlayerB,p.x,p.y); lcd.copy_to_lcd(); - wait(0.5); + wait(0.02); } -} - - - - - +} \ No newline at end of file