#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;
}
    

    