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@2:23b20cbd3330, 2017-05-01 (annotated)
- Committer:
- weixitao
- Date:
- Mon May 01 16:37:53 2017 +0000
- Revision:
- 2:23b20cbd3330
- Parent:
- 1:83459533ff72
four ares and win to 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 | 2:23b20cbd3330 | 8 | int four = ((rand())%4)+1; |
| weixitao | 2:23b20cbd3330 | 9 | switch(four){ |
| weixitao | 2:23b20cbd3330 | 10 | case 1: |
| weixitao | 0:1465fd20e75b | 11 | //top left |
| weixitao | 0:1465fd20e75b | 12 | holeX = rand()%27+5; |
| weixitao | 0:1465fd20e75b | 13 | holeY = rand()%14+5; |
| weixitao | 2:23b20cbd3330 | 14 | break; |
| weixitao | 2:23b20cbd3330 | 15 | |
| weixitao | 2:23b20cbd3330 | 16 | case 2: |
| weixitao | 0:1465fd20e75b | 17 | // top right |
| weixitao | 2:23b20cbd3330 | 18 | holeX = rand()%27+47; |
| weixitao | 2:23b20cbd3330 | 19 | holeY = rand()%14+5; |
| weixitao | 2:23b20cbd3330 | 20 | break; |
| weixitao | 0:1465fd20e75b | 21 | |
| weixitao | 2:23b20cbd3330 | 22 | case 3: |
| weixitao | 0:1465fd20e75b | 23 | // button left |
| weixitao | 2:23b20cbd3330 | 24 | holeX = rand()%27+5; |
| weixitao | 2:23b20cbd3330 | 25 | holeY = rand()%14+29; |
| weixitao | 2:23b20cbd3330 | 26 | break; |
| weixitao | 0:1465fd20e75b | 27 | |
| weixitao | 2:23b20cbd3330 | 28 | case 4: |
| weixitao | 0:1465fd20e75b | 29 | //button right |
| weixitao | 2:23b20cbd3330 | 30 | holeX = rand()%27+47; |
| weixitao | 2:23b20cbd3330 | 31 | holeY = rand()%14+29; |
| weixitao | 2:23b20cbd3330 | 32 | break; |
| weixitao | 2:23b20cbd3330 | 33 | }} |
| weixitao | 0:1465fd20e75b | 34 | |
| weixitao | 0:1465fd20e75b | 35 | void hole::hole_show() |
| weixitao | 0:1465fd20e75b | 36 | { |
| weixitao | 0:1465fd20e75b | 37 | |
| weixitao | 1:83459533ff72 | 38 | lcd.drawCircle(holeX,holeY,3,FILL_BLACK); |
| weixitao | 1:83459533ff72 | 39 | // lcd.drawCircle(holeX1,holeY1,3,FILL_BLACK); |
| weixitao | 1:83459533ff72 | 40 | // lcd.drawCircle(holeX2,holeY2,3,FILL_BLACK); |
| weixitao | 1:83459533ff72 | 41 | // lcd.drawCircle(holeX3,holeY3,3,FILL_BLACK); |
| weixitao | 1:83459533ff72 | 42 | |
| weixitao | 1:83459533ff72 | 43 | |
| weixitao | 1:83459533ff72 | 44 | } |
| weixitao | 0:1465fd20e75b | 45 | |
| weixitao | 0:1465fd20e75b | 46 | |
| weixitao | 1:83459533ff72 | 47 | bool hole::test(int _x, int _y) |
| weixitao | 1:83459533ff72 | 48 | { |
| weixitao | 1:83459533ff72 | 49 | |
| weixitao | 1:83459533ff72 | 50 | int x = _x; |
| weixitao | 1:83459533ff72 | 51 | int y = _y; |
| weixitao | 1:83459533ff72 | 52 | |
| weixitao | 1:83459533ff72 | 53 | bool check = false; |
| weixitao | 1:83459533ff72 | 54 | |
| weixitao | 2:23b20cbd3330 | 55 | if(x+41-3 <=holeX && holeX <=41+x+1+3 && y+24-3 <=holeY && y+24+6 >=holeY ) |
| weixitao | 1:83459533ff72 | 56 | { |
| weixitao | 1:83459533ff72 | 57 | printf("Check"); |
| weixitao | 1:83459533ff72 | 58 | check = true; |
| weixitao | 1:83459533ff72 | 59 | } |
| weixitao | 1:83459533ff72 | 60 | |
| weixitao | 1:83459533ff72 | 61 | return check; |
| weixitao | 1:83459533ff72 | 62 | } |
| weixitao | 1:83459533ff72 | 63 | |
| weixitao | 1:83459533ff72 | 64 | |
| weixitao | 1:83459533ff72 | 65 |