ELEC2645 (2018/19) / Mbed 2 deprecated EL17MCD

Dependencies:   mbed

TankL/TankL.cpp

Committer:
el17mcd
Date:
2019-04-10
Revision:
8:d4e419dad90f
Parent:
7:a3ccabdebe2e
Child:
10:d4fb12e9e7cd

File content as of revision 8:d4e419dad90f:

/* TankL.cpp
Produces tank on the left side of the
lcd and dictates it's movement
1.4.19
*/
#include "TankL.h"
/*
TankL::TankL()
{

}

TankL::~TankL()
{

}
*/
void TankL::draw(N5110 &lcd)
{
    const int tank_l_spr[6][10] =   {
        { 0,0,0,1,1,1,0,0,0,0 },
        { 0,0,1,1,1,1,1,0,0,0 },
        { 0,0,1,1,1,1,1,1,1,0 },
        { 1,1,1,1,1,1,1,1,1,1 },
        { 1,0,1,0,1,0,1,0,1,0 },
        { 0,1,0,1,0,1,0,1,0,0 },                                                                
    };
    lcd.drawSprite(_position_x,42 - _position_y,6,10,(int *)tank_l_spr);
}

void TankL::set_position(int x, int y)
{
    _position_x = x;
    _position_y = y;
}

int TankL::get_position_x()
{
    return _position_x;
}

int TankL::get_position_y()
{
    return _position_y;
}

int TankL::get_hitbox(int i)
{
    return _hitbox[i];
}

void TankL::set_health(int h)
{
    _health = h;   
}

void TankL::lose_health()
{
    _health--;
/*    if (_health <= 0) right player wins
{} */
}

void TankL::generate_hitbox()
{
    int i = 0;
    for (int i0 = 0; i0 < 4; i0++) {    
        for (int i1 = 1; i1 < 11; i1++) {
            _hitbox[i] = (i0 + _position_y) * 84 + _position_x + i1;
            i++;
        }
    }
}