Joe Shotton / Mbed 2 deprecated ELEC2645_Project_ll16j23s

Dependencies:   mbed ll16j23s_test_docs

Food/Food.cpp

Committer:
JoeShotton
Date:
2020-05-20
Revision:
3:fcd6d70e9694
Child:
4:ea3fa51c4386

File content as of revision 3:fcd6d70e9694:

#include "Food.h"

Food::Food()
{
//constructor
}

Food::~Food()
{
//deconstructor
}

void Food::init()
{
    _x = 84; // starts off-screen
    _y = 0; 
    //srand (x); //CHANGE THIS TO ACCELERAOMETRE VALUE
}


Vector2D Food::rand_pos(int cell_size) {
    
    int _x = cell_size * (rand() % 42); //selects random x cell 
    printf("Food x: %d\n", _x);
    int _y = cell_size * (rand() % 24); //selects random y call
    printf("Food y: %d\n", _y);
    Vector2D pos = {_x,_y};
    return pos;    
}


void Food::draw(N5110 &lcd, int frame)
{
    // draw food, with alternate locations depending on frame. 
    lcd.drawLine(_x + frame, _y, _x + 1 - frame,_y + 1,1);
}