Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Human/human.cpp@3:dd4678a85a1a, 2017-05-04 (annotated)
- Committer:
- weixitao
- Date:
- Thu May 04 13:56:12 2017 +0000
- Revision:
- 3:dd4678a85a1a
- Parent:
- human.cpp@1:83459533ff72
befor submit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| weixitao | 1:83459533ff72 | 1 | #include "human.h" |
| weixitao | 1:83459533ff72 | 2 | extern N5110 lcd; |
| weixitao | 1:83459533ff72 | 3 | extern Gamepad pad; |
| weixitao | 1:83459533ff72 | 4 | |
| weixitao | 1:83459533ff72 | 5 | |
| weixitao | 1:83459533ff72 | 6 | double human::humanX() |
| weixitao | 1:83459533ff72 | 7 | { |
| weixitao | 1:83459533ff72 | 8 | while(1) { |
| weixitao | 1:83459533ff72 | 9 | Vector2D human_x = pad.get_coord(); |
| weixitao | 1:83459533ff72 | 10 | x = (int)(human_x.x*40); //-1 to 1. |
| weixitao | 1:83459533ff72 | 11 | |
| weixitao | 1:83459533ff72 | 12 | //printf("The value of x(sight) is %i\n",x); |
| weixitao | 1:83459533ff72 | 13 | |
| weixitao | 1:83459533ff72 | 14 | return x; |
| weixitao | 1:83459533ff72 | 15 | |
| weixitao | 1:83459533ff72 | 16 | |
| weixitao | 1:83459533ff72 | 17 | } |
| weixitao | 1:83459533ff72 | 18 | } |
| weixitao | 1:83459533ff72 | 19 | |
| weixitao | 1:83459533ff72 | 20 | |
| weixitao | 1:83459533ff72 | 21 | double human::humanY() |
| weixitao | 1:83459533ff72 | 22 | { |
| weixitao | 1:83459533ff72 | 23 | while(1) { |
| weixitao | 1:83459533ff72 | 24 | Vector2D human_y = pad.get_coord(); |
| weixitao | 1:83459533ff72 | 25 | y = (int)(-19*human_y.y)-6; //-1 to 1 |
| weixitao | 1:83459533ff72 | 26 | |
| weixitao | 1:83459533ff72 | 27 | //printf("The value of y(sight) is %i\n",y); |
| weixitao | 1:83459533ff72 | 28 | |
| weixitao | 1:83459533ff72 | 29 | return y; |
| weixitao | 1:83459533ff72 | 30 | } |
| weixitao | 1:83459533ff72 | 31 | } |
| weixitao | 1:83459533ff72 | 32 | |
| weixitao | 1:83459533ff72 | 33 | |
| weixitao | 1:83459533ff72 | 34 | void human:: print_human() |
| weixitao | 1:83459533ff72 | 35 | { |
| weixitao | 1:83459533ff72 | 36 | lcd.drawRect(41+x,24+y,3,3,FILL_BLACK); //head |
| weixitao | 1:83459533ff72 | 37 | lcd.drawLine(41+x+1,24+y+3,41+x+1,24+y+6,1); //body |
| weixitao | 1:83459533ff72 | 38 | lcd.drawLine(41+x,24+y+4,41+x+2,24+y+4,1);// hands |
| weixitao | 1:83459533ff72 | 39 | lcd.drawLine(41+x+1,24+y+6,41+x,24+y+7,1);// left leg |
| weixitao | 1:83459533ff72 | 40 | lcd.drawLine(41+x+1,24+y+6,41+x+2,24+y+7,1);// right leg |
| weixitao | 1:83459533ff72 | 41 | |
| weixitao | 1:83459533ff72 | 42 | lcd.refresh(); |
| weixitao | 1:83459533ff72 | 43 | |
| weixitao | 1:83459533ff72 | 44 | |
| weixitao | 1:83459533ff72 | 45 | |
| weixitao | 1:83459533ff72 | 46 | } |