Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
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
Generated on Sat Jul 16 2022 21:38:04 by
1.7.2