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/hole.cpp
- Committer:
- weixitao
- Date:
- 2017-05-05
- Revision:
- 4:402c27b212c1
- Parent:
- 3:dd4678a85a1a
File content as of revision 4:402c27b212c1:
#include "N5110.h"
#include "hole.h"
extern N5110 lcd;
//
/** Hole place *
* lot out the screen in four parts and the bomb would produce in random place of four parts
* @param holex - the column number of bomb center
* @param holey - the row number of bomb center */
void hole::hole_place()
{
int four = ((rand())%4)+1;
switch(four){
case 1:
//top left
holeX = rand()%27+5;
holeY = rand()%14+5;
break;
case 2:
// top right
holeX = rand()%27+47;
holeY = rand()%14+5;
break;
case 3:
// bass left
holeX = rand()%27+5;
holeY = rand()%14+29;
break;
case 4:
//bass right
holeX = rand()%27+47;
holeY = rand()%14+29;
break;
}}
void hole::hole_show()
{
lcd.drawCircle(holeX,holeY,3,FILL_BLACK);
}
/** Hole test *
* Test when human touch the hole
*/
bool hole::test(int _x, int _y)
{
int x = _x;
int y = _y;
bool check = false;
//when human touch the hole
if(x+41-3 <=holeX && holeX <=41+x+1+3 && y+24-3 <=holeY && y+24+6 >=holeY )
{
printf("Check");
check = true;
}
return check;
}