Final Commit

Dependencies:   mbed

Food/Food.cpp

Committer:
JRM1986
Date:
2018-03-22
Revision:
8:a2b431b9b3f7
Parent:
7:c38800a428a6
Child:
9:561e5681b7a6

File content as of revision 8:a2b431b9b3f7:

#include "Food.h"


Food::Food()
{

}

Food::~Food()
{

}
void Food::init(int pos_x, int pos_y)
{
    _x = pos_x;
    _y = pos_y;    
}

void Food::update() 
{
    Vector2D values = get_rand_pos();
    
    _x = values.x;
    _y = values.y;
       
}
  
void Food::draw(N5110 &lcd) 
{

    lcd.setPixel(_x,_y,true);
    
}     


Vector2D Food::get_rand_pos()
{
    
    Vector2D r;
    
    srand(time(NULL));
    
    r.x = rand() % 84;
    r.y = rand() % 48;
    
    return r;
    
}