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.
Diff: Health_Kit/Health_Kit.cpp
- Revision:
- 3:aa82968b7a8e
- Child:
- 15:807eba7c7811
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Health_Kit/Health_Kit.cpp Thu Apr 25 15:08:52 2019 +0000 @@ -0,0 +1,61 @@ +#include "Health_Kit.h" + +// nothing doing in the constructor and destructor +Health_Kit::Health_Kit() +{ + +} + +Health_Kit::~Health_Kit() +{ + +} + +/** +* This method will be used to initialise the health_kit variables. +* Saves global variables to local variables. +* @author Oliver Luong +* @param kit_size +* @date 22/04/2019 +*/ +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 +} + +/** +* This method will be used to store the sprite for health_kit and draw it +* onto the LCD. +* @author Oliver Luong +* @date 22/04/2019 +*/ +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 +} + +/** +* This method will be used to return the postion of the health_kit when called. +* @author Oliver Luong +* @date 22/04/2019 +*/ +Vector2D Health_Kit::get_pos() +{ + Vector2D p = {_x,_y}; + return p; +} \ No newline at end of file