Implement basic functions

Dependencies:   mbed N5110

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Begin.cpp Source File

Begin.cpp

00001 #include "Begin.h"
00002 
00003 Begin::Begin()
00004 {
00005     
00006 }
00007 
00008 Begin::~Begin()
00009 {
00010     
00011 }
00012 
00013 void Begin::init()
00014 {
00015     _m = 0;
00016     _s = 0;
00017     _a1 = 0;
00018     _b1 = 0;
00019     _a2 = 0;
00020     _b2 = 0;
00021     _a3 = 0;
00022     _b3 = 0;
00023     _h = 0;
00024     _Bird.init();
00025     _Wall.init();
00026 }
00027 
00028 int Begin::draw(N5110 &lcd, Gamepad &pad)
00029 {
00030     lcd.drawRect(0,8,84,40,FILL_TRANSPARENT);
00031     int* _ab = new int[7];
00032     _ab = _Wall.draw(lcd);
00033     _a1 = _ab[0];
00034     _b1 = _ab[1];
00035     _a2 = _ab[2];
00036     _b2 = _ab[3];
00037     _a3 = _ab[4];
00038     _b3 = _ab[5];
00039     _s = _ab[6];
00040     _h = _Bird.draw(lcd, pad);
00041     char buffer1[14];
00042     sprintf(buffer1,"score: %2d ",_s);
00043     lcd.printString(buffer1,0,0);
00044     if(_a1 == 0){
00045         if(_h+2 <= _b1+1 | _h+8 >= _b1+15){
00046             _m = 1;
00047         }else{
00048             _m = 0;
00049         }
00050     }
00051     if(_a2 == 0){
00052         if(_h+2 <= _b2+1 | _h+8 >= _b2+15){
00053             _m = 1;
00054         }else{
00055             _m = 0;
00056         }
00057     }
00058     if(_a3 == 0){
00059         if(_h+2 <= _b3+1 | _h+8 >= _b3+15){
00060             _m = 1;
00061         }else{
00062             _m = 0;
00063         }
00064     }
00065     if(_h+2 <= 0 | _h+8 >= 48){
00066         _m = 1;
00067     }
00068     return _m;
00069 }