ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18s2a_2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Apple.cpp Source File

Apple.cpp

00001 #include "Apple.h"
00002 
00003 // nothing doing in the constructor and destructor
00004 Apple::Apple()
00005 {
00006 
00007 }
00008 
00009 Apple::~Apple()
00010 {
00011 
00012 }
00013 
00014 void Apple::init(int size)  //The inital settings for the apple size and location size is set in main.cpp
00015 {
00016      _size = size;
00017      srand(time(NULL)); 
00018     _x = (rand() % (WIDTH));        
00019     _y = (rand() % (HEIGHT));   
00020   
00021 }
00022 
00023 void Apple::draw(N5110 &lcd)
00024 {
00025     // draw the food
00026    lcd.drawCircle(_x, _y, _size, FILL_BLACK);   // Draws a circle representing an apple
00027 }
00028 
00029 Vector2D Apple::get_pos ()
00030 {
00031     Vector2D p = {_x,_y};   // Getting the position of the apple
00032     return p;}
00033  
00034