Implement basic functions

Dependencies:   mbed N5110

Begin/Begin.cpp

Committer:
Wuuu
Date:
2019-05-03
Revision:
0:64bd9f996099

File content as of revision 0:64bd9f996099:

#include "Begin.h"

Begin::Begin()
{
    
}

Begin::~Begin()
{
    
}

void Begin::init()
{
    _m = 0;
    _s = 0;
    _a1 = 0;
    _b1 = 0;
    _a2 = 0;
    _b2 = 0;
    _a3 = 0;
    _b3 = 0;
    _h = 0;
    _Bird.init();
    _Wall.init();
}

int Begin::draw(N5110 &lcd, Gamepad &pad)
{
    lcd.drawRect(0,8,84,40,FILL_TRANSPARENT);
    int* _ab = new int[7];
    _ab = _Wall.draw(lcd);
    _a1 = _ab[0];
    _b1 = _ab[1];
    _a2 = _ab[2];
    _b2 = _ab[3];
    _a3 = _ab[4];
    _b3 = _ab[5];
    _s = _ab[6];
    _h = _Bird.draw(lcd, pad);
    char buffer1[14];
    sprintf(buffer1,"score: %2d ",_s);
    lcd.printString(buffer1,0,0);
    if(_a1 == 0){
        if(_h+2 <= _b1+1 | _h+8 >= _b1+15){
            _m = 1;
        }else{
            _m = 0;
        }
    }
    if(_a2 == 0){
        if(_h+2 <= _b2+1 | _h+8 >= _b2+15){
            _m = 1;
        }else{
            _m = 0;
        }
    }
    if(_a3 == 0){
        if(_h+2 <= _b3+1 | _h+8 >= _b3+15){
            _m = 1;
        }else{
            _m = 0;
        }
    }
    if(_h+2 <= 0 | _h+8 >= 48){
        _m = 1;
    }
    return _m;
}