Implement basic functions.

Dependencies:   mbed N5110

Committer:
Wuuu
Date:
Fri May 03 13:03:59 2019 +0000
Revision:
0:7173d91b03e1
Copter, which with header programme.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wuuu 0:7173d91b03e1 1 #include "Game1.h"
Wuuu 0:7173d91b03e1 2
Wuuu 0:7173d91b03e1 3 Game1::Game1()
Wuuu 0:7173d91b03e1 4 {
Wuuu 0:7173d91b03e1 5
Wuuu 0:7173d91b03e1 6 }
Wuuu 0:7173d91b03e1 7
Wuuu 0:7173d91b03e1 8 Game1::~Game1()
Wuuu 0:7173d91b03e1 9 {
Wuuu 0:7173d91b03e1 10
Wuuu 0:7173d91b03e1 11 }
Wuuu 0:7173d91b03e1 12
Wuuu 0:7173d91b03e1 13 void Game1::init()
Wuuu 0:7173d91b03e1 14 {
Wuuu 0:7173d91b03e1 15 _m = 0;
Wuuu 0:7173d91b03e1 16 _s = 0;
Wuuu 0:7173d91b03e1 17 _a = 20;
Wuuu 0:7173d91b03e1 18 _b = 20;
Wuuu 0:7173d91b03e1 19 _Wall.init();
Wuuu 0:7173d91b03e1 20 _Copter.init();
Wuuu 0:7173d91b03e1 21 }
Wuuu 0:7173d91b03e1 22
Wuuu 0:7173d91b03e1 23 int Game1::draw(N5110 &lcd, Gamepad &pad)
Wuuu 0:7173d91b03e1 24 {
Wuuu 0:7173d91b03e1 25 lcd.drawRect(0,8,84,40,FILL_TRANSPARENT);
Wuuu 0:7173d91b03e1 26 _Wall.draw(lcd);
Wuuu 0:7173d91b03e1 27 _Copter.get_coord(pad);
Wuuu 0:7173d91b03e1 28 _Copter.get_h();
Wuuu 0:7173d91b03e1 29 _Copter.draw(lcd);
Wuuu 0:7173d91b03e1 30 _s = _Copter.get_score();
Wuuu 0:7173d91b03e1 31 char buffer1[14];
Wuuu 0:7173d91b03e1 32 sprintf(buffer1,"score: %2d ",_s);
Wuuu 0:7173d91b03e1 33 lcd.printString(buffer1,0,0);
Wuuu 0:7173d91b03e1 34 int* _ab = new int[2];
Wuuu 0:7173d91b03e1 35 _ab = _Wall.draw(lcd);
Wuuu 0:7173d91b03e1 36 _a = _ab[0];
Wuuu 0:7173d91b03e1 37 _b = _ab[1];
Wuuu 0:7173d91b03e1 38 _c = _Copter.get_h();
Wuuu 0:7173d91b03e1 39 int d = 8 + _b - _a;
Wuuu 0:7173d91b03e1 40 int e = 8 + _b + _a;
Wuuu 0:7173d91b03e1 41 if(d >= 21-_c | e <= 27-_c){
Wuuu 0:7173d91b03e1 42 _m = 1;
Wuuu 0:7173d91b03e1 43 }else{
Wuuu 0:7173d91b03e1 44 _m = 0;
Wuuu 0:7173d91b03e1 45 }
Wuuu 0:7173d91b03e1 46 return _m;
Wuuu 0:7173d91b03e1 47 }
Wuuu 0:7173d91b03e1 48