ELEC2645 (2018/19) / Mbed 2 deprecated ll16o2l_ELEC2645

Dependencies:   mbed Gamepad

Health_Kit/Health_Kit.cpp

Committer:
ll16o2l
Date:
2019-05-07
Revision:
15:807eba7c7811
Parent:
3:aa82968b7a8e

File content as of revision 15:807eba7c7811:

#include "Health_Kit.h"

// nothing doing in the constructor and destructor
Health_Kit::Health_Kit()
{

}

Health_Kit::~Health_Kit()
{

}

void Health_Kit::init(int kit_size){
    _kit_size = kit_size;
    _x_edge = WIDTH -  _kit_size/2; // Edge of horizontal
    _y_edge = HEIGHT - _kit_size/2; // Edge of vertical
    
    
    _x = rand() % _x_edge; // Generate random position on the screen - 0 to the edge
    _y = rand() % _y_edge; // Generate random position on the screen - 0 to the edge 
}

void Health_Kit::draw(N5110 &lcd)
{
    int Health_Kit_sprite[7][7] = {
        {1,1,1,1,1,1,1},
        {1,0,0,0,0,0,1},
        {1,0,0,1,0,0,1},
        {1,0,1,1,1,0,1},
        {1,0,0,1,0,0,1},
        {1,0,0,0,0,0,1},
        {1,1,1,1,1,1,1},
    };
    
    lcd.drawSprite(_x,_y,7,7,(int*)Health_Kit_sprite);  // x,y,radius,black fill
}

Vector2D Health_Kit::get_pos()
{
    Vector2D p = {_x,_y};
    return p;
}