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
hole.cpp@1:83459533ff72, 2017-05-01 (annotated)
- Committer:
- weixitao
- Date:
- Mon May 01 15:20:26 2017 +0000
- Revision:
- 1:83459533ff72
- Parent:
- 0:1465fd20e75b
- Child:
- 2:23b20cbd3330
until welcome
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| weixitao | 0:1465fd20e75b | 1 | #include "Treasure.h" |
| weixitao | 0:1465fd20e75b | 2 | #include "N5110.h" |
| weixitao | 0:1465fd20e75b | 3 | #include "hole.h" |
| weixitao | 0:1465fd20e75b | 4 | extern N5110 lcd; |
| weixitao | 0:1465fd20e75b | 5 | |
| weixitao | 0:1465fd20e75b | 6 | void hole::hole_place() |
| weixitao | 0:1465fd20e75b | 7 | { |
| weixitao | 0:1465fd20e75b | 8 | |
| weixitao | 0:1465fd20e75b | 9 | //top left |
| weixitao | 0:1465fd20e75b | 10 | holeX = rand()%27+5; |
| weixitao | 0:1465fd20e75b | 11 | holeY = rand()%14+5; |
| weixitao | 0:1465fd20e75b | 12 | |
| weixitao | 0:1465fd20e75b | 13 | // top right |
| weixitao | 0:1465fd20e75b | 14 | holeX1 = rand()%27+47; |
| weixitao | 0:1465fd20e75b | 15 | holeY1 = rand()%14+5; |
| weixitao | 0:1465fd20e75b | 16 | |
| weixitao | 0:1465fd20e75b | 17 | // button left |
| weixitao | 0:1465fd20e75b | 18 | holeX2 = rand()%27+5; |
| weixitao | 0:1465fd20e75b | 19 | holeY2 = rand()%14+29; |
| weixitao | 0:1465fd20e75b | 20 | |
| weixitao | 0:1465fd20e75b | 21 | //button right |
| weixitao | 0:1465fd20e75b | 22 | holeX3 = rand()%27+47; |
| weixitao | 0:1465fd20e75b | 23 | holeY3 = rand()%14+29; |
| weixitao | 0:1465fd20e75b | 24 | } |
| weixitao | 0:1465fd20e75b | 25 | |
| weixitao | 0:1465fd20e75b | 26 | void hole::hole_show() |
| weixitao | 0:1465fd20e75b | 27 | { |
| weixitao | 0:1465fd20e75b | 28 | |
| weixitao | 1:83459533ff72 | 29 | lcd.drawCircle(holeX,holeY,3,FILL_BLACK); |
| weixitao | 1:83459533ff72 | 30 | // lcd.drawCircle(holeX1,holeY1,3,FILL_BLACK); |
| weixitao | 1:83459533ff72 | 31 | // lcd.drawCircle(holeX2,holeY2,3,FILL_BLACK); |
| weixitao | 1:83459533ff72 | 32 | // lcd.drawCircle(holeX3,holeY3,3,FILL_BLACK); |
| weixitao | 1:83459533ff72 | 33 | |
| weixitao | 1:83459533ff72 | 34 | |
| weixitao | 1:83459533ff72 | 35 | } |
| weixitao | 0:1465fd20e75b | 36 | |
| weixitao | 0:1465fd20e75b | 37 | |
| weixitao | 1:83459533ff72 | 38 | bool hole::test(int _x, int _y) |
| weixitao | 1:83459533ff72 | 39 | { |
| weixitao | 1:83459533ff72 | 40 | |
| weixitao | 1:83459533ff72 | 41 | int x = _x; |
| weixitao | 1:83459533ff72 | 42 | int y = _y; |
| weixitao | 1:83459533ff72 | 43 | |
| weixitao | 1:83459533ff72 | 44 | bool check = false; |
| weixitao | 1:83459533ff72 | 45 | |
| weixitao | 1:83459533ff72 | 46 | if(x+41-3 <=holeX && holeX <=41+x+1+3 && y+24-3 <=holeY && y+24+6 >=holeY) |
| weixitao | 1:83459533ff72 | 47 | { |
| weixitao | 1:83459533ff72 | 48 | printf("Check"); |
| weixitao | 1:83459533ff72 | 49 | check = true; |
| weixitao | 1:83459533ff72 | 50 | } |
| weixitao | 1:83459533ff72 | 51 | |
| weixitao | 1:83459533ff72 | 52 | return check; |
| weixitao | 1:83459533ff72 | 53 | } |
| weixitao | 1:83459533ff72 | 54 | |
| weixitao | 1:83459533ff72 | 55 | |
| weixitao | 1:83459533ff72 | 56 |