![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
test avoid bulled game
Dependencies: C12832_lcd LCD_fonts mbed mbed-rtos
main.cpp@10:7b2cf5e89e65, 2016-12-05 (annotated)
- Committer:
- kaku_jyoko
- Date:
- Mon Dec 05 08:13:40 2016 +0000
- Revision:
- 10:7b2cf5e89e65
- Parent:
- 7:defdc7cb4e0b
- Child:
- 11:cf3cf60589f4
add bullet graphic
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
th_mbed | 0:26e5e770f91b | 1 | #include "mbed.h" |
th_mbed | 0:26e5e770f91b | 2 | #include "C12832_lcd.h" |
th_mbed | 0:26e5e770f91b | 3 | #include "Arial_9.h" |
th_mbed | 0:26e5e770f91b | 4 | #include "Small_7.h" |
th_mbed | 0:26e5e770f91b | 5 | #include "graphics.h" |
kaku_jyoko | 4:0fe59e58def9 | 6 | #include "models.h" |
kaku_jyoko | 4:0fe59e58def9 | 7 | #include "rtos.h" |
kaku_jyoko | 5:651879f4f047 | 8 | #include "point.h" |
th_mbed | 0:26e5e770f91b | 9 | |
th_mbed | 0:26e5e770f91b | 10 | C12832_LCD lcd; |
th_mbed | 0:26e5e770f91b | 11 | |
kaku_jyoko | 4:0fe59e58def9 | 12 | // down: p12, left: p13, center: p14, up: p15, right: p16 |
kaku_jyoko | 5:651879f4f047 | 13 | InterruptIn button(p14); |
kaku_jyoko | 5:651879f4f047 | 14 | DigitalOut led1(LED1); |
kaku_jyoko | 4:0fe59e58def9 | 15 | |
kaku_jyoko | 5:651879f4f047 | 16 | Mutex jump_mtx; |
kaku_jyoko | 5:651879f4f047 | 17 | Mutex update_mtx; |
kaku_jyoko | 4:0fe59e58def9 | 18 | int jump_flag = 0; |
kaku_jyoko | 6:e63641e13374 | 19 | Person h; |
kaku_jyoko | 4:0fe59e58def9 | 20 | |
kaku_jyoko | 5:651879f4f047 | 21 | void a(){ |
kaku_jyoko | 6:e63641e13374 | 22 | h.jump(); |
kaku_jyoko | 4:0fe59e58def9 | 23 | } |
kaku_jyoko | 4:0fe59e58def9 | 24 | |
kaku_jyoko | 4:0fe59e58def9 | 25 | void receive(void const *argument){ |
kaku_jyoko | 4:0fe59e58def9 | 26 | while(true){ |
kaku_jyoko | 6:e63641e13374 | 27 | jump_mtx.lock(); |
kaku_jyoko | 6:e63641e13374 | 28 | button.rise(&a); |
kaku_jyoko | 6:e63641e13374 | 29 | jump_mtx.unlock(); |
kaku_jyoko | 6:e63641e13374 | 30 | //Thread::wait(0.1); |
th_mbed | 0:26e5e770f91b | 31 | } |
kaku_jyoko | 5:651879f4f047 | 32 | } |
kaku_jyoko | 5:651879f4f047 | 33 | |
kaku_jyoko | 5:651879f4f047 | 34 | |
kaku_jyoko | 5:651879f4f047 | 35 | |
kaku_jyoko | 5:651879f4f047 | 36 | int main(){ |
kaku_jyoko | 5:651879f4f047 | 37 | point p; |
kaku_jyoko | 5:651879f4f047 | 38 | printf("hello\n"); |
kaku_jyoko | 5:651879f4f047 | 39 | Thread receive_th(receive); |
kaku_jyoko | 5:651879f4f047 | 40 | while(true){ |
kaku_jyoko | 5:651879f4f047 | 41 | update_mtx.lock(); |
kaku_jyoko | 5:651879f4f047 | 42 | p = h.update(); |
kaku_jyoko | 7:defdc7cb4e0b | 43 | if(p.y == 0){ |
kaku_jyoko | 7:defdc7cb4e0b | 44 | } |
kaku_jyoko | 5:651879f4f047 | 45 | update_mtx.unlock(); |
kaku_jyoko | 6:e63641e13374 | 46 | lcd.cls(); |
kaku_jyoko | 6:e63641e13374 | 47 | lcd.print_bm(bitmPlayer,p.x,p.y); |
kaku_jyoko | 10:7b2cf5e89e65 | 48 | lcd.print_bm(bitmBullet_graphics, 40, 10); |
kaku_jyoko | 5:651879f4f047 | 49 | lcd.copy_to_lcd(); |
kaku_jyoko | 6:e63641e13374 | 50 | wait(0.02); |
kaku_jyoko | 6:e63641e13374 | 51 | lcd.cls(); |
kaku_jyoko | 6:e63641e13374 | 52 | lcd.print_bm(bitmPlayerB,p.x,p.y); |
kaku_jyoko | 5:651879f4f047 | 53 | lcd.copy_to_lcd(); |
kaku_jyoko | 6:e63641e13374 | 54 | wait(0.02); |
kaku_jyoko | 5:651879f4f047 | 55 | } |
kaku_jyoko | 6:e63641e13374 | 56 | } |