Implement basic functions.

Dependencies:   mbed N5110

Wall/Wall.cpp

Committer:
Wuuu
Date:
2019-05-03
Revision:
0:7173d91b03e1

File content as of revision 0:7173d91b03e1:

#include "Wall.h"

Wall::Wall()
{

}

Wall::~Wall()
{

}

void Wall::init() 
{
    _a1 = 20;
    _a2 = 20;
    _a3 = 20;
    _a4 = 20;
    _a5 = 20;
    _a6 = 20;
    _a7 = 20;
    _a8 = 20;
    _a9 = 20;
    _a10 = 20;
    _a11 = 20;
    _a12 = 20;
    _b1 = 20;
    _b2 = 20;
    _b3 = 20;
    _b4 = 20;
    _b5 = 20;
    _b6 = 20;
    _b7 = 20;
    _b8 = 20;
    _b9 = 20;
    _b10 = 20;
    _b11 = 20;
    _b12 = 20;
    _ab = new int[2];
    _ab[0] = 0;
    _ab[1] = 0;
}

int* Wall::draw(N5110 &lcd)
{
    _a1 = _a2;
    _a2 = _a3;
    _a3 = _a4;
    _a4 = _a5;
    _a5 = _a6;
    _a6 = _a7;
    _a7 = _a8;
    _a8 = _a9;
    _a9 = _a10;
    _a10 = _a11;
    _a11 = _a12;
    _a12 = rand() % 10 + 5;
    _b1 = _b2;
    _b2 = _b3;
    _b3 = _b4;
    _b4 = _b5;
    _b5 = _b6;
    _b6 = _b7;
    _b7 = _b8;
    _b8 = _b9;
    _b9 = _b10;
    _b10 = _b11;
    _b11 = _b12;
    _b12 = rand() % 6 + 14;
    lcd.drawRect(0,8,7,_b1-_a1,FILL_BLACK);
    lcd.drawRect(0,8+_a1+_b1,7,40-_a1-_b1,FILL_BLACK);
    lcd.drawRect(7,8,7,_b2-_a2,FILL_BLACK);
    lcd.drawRect(7,8+_a2+_b2,7,40-_a2-_b2,FILL_BLACK);
    lcd.drawRect(14,8,7,_b3-_a3,FILL_BLACK);
    lcd.drawRect(14,8+_a3+_b3,7,40-_a3-_b3,FILL_BLACK);
    lcd.drawRect(21,8,7,_b4-_a4,FILL_BLACK);
    lcd.drawRect(21,8+_a4+_b4,7,40-_a4-_b4,FILL_BLACK);
    lcd.drawRect(28,8,7,_b5-_a5,FILL_BLACK);
    lcd.drawRect(28,8+_a5+_b5,7,40-_a5-_b5,FILL_BLACK);
    lcd.drawRect(35,8,7,_b6-_a6,FILL_BLACK);
    lcd.drawRect(35,8+_a6+_b6,7,40-_a6-_b6,FILL_BLACK);
    lcd.drawRect(42,8,7,_b7-_a7,FILL_BLACK);
    lcd.drawRect(42,8+_a7+_b7,7,40-_a7-_b7,FILL_BLACK);
    lcd.drawRect(49,8,7,_b8-_a8,FILL_BLACK);
    lcd.drawRect(49,8+_a8+_b8,7,40-_a8-_b8,FILL_BLACK);
    lcd.drawRect(56,8,7,_b9-_a9,FILL_BLACK);
    lcd.drawRect(56,8+_a9+_b9,7,40-_a9-_b9,FILL_BLACK);
    lcd.drawRect(63,8,7,_b10-_a10,FILL_BLACK);
    lcd.drawRect(63,8+_a10+_b10,7,40-_a10-_b10,FILL_BLACK);
    lcd.drawRect(70,8,7,_b11-_a11,FILL_BLACK);
    lcd.drawRect(70,8+_a11+_b11,7,40-_a11-_b11,FILL_BLACK);
    lcd.drawRect(77,8,7,_b12-_a12,FILL_BLACK);
    lcd.drawRect(77,8+_a12+_b12,7,40-_a12-_b12,FILL_BLACK);
    _ab[0] = _a1;
    _ab[1] = _b1;
    return _ab;
}