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 FXOS8700CQ mbed-rtos
Diff: Game_two/Insta_files/Insta.cpp
- Revision:
- 33:f7ec806e14b6
- Parent:
- 26:c60becf3f840
--- a/Game_two/Insta_files/Insta.cpp Wed May 08 15:14:55 2019 +0000 +++ b/Game_two/Insta_files/Insta.cpp Wed May 08 23:57:04 2019 +0000 @@ -10,6 +10,7 @@ } +// Function to initiate the instagram icon void Insta::init(int speed) { int position = rand() % 8; // randomise initial direction and position. @@ -58,6 +59,7 @@ } } +// Function to draw the instagram icon according to the updated position void Insta::draw(N5110 &lcd) { int Insta_data[12][12] = { @@ -78,30 +80,35 @@ lcd.drawSprite(_x, _y, 12, 12, (int*)Insta_data); } +// Update the position of the instagram icon dependent on the speed void Insta::update() { _x += _velocity.x; _y += _velocity.y; } +// Function used to set the velocity of the instagram icon void Insta::set_velocity(Vector2D v) { _velocity.x = v.x; _velocity.y = v.y; } +// Function used to fetch the current velocity of the instagram icon Vector2D Insta::get_velocity() { Vector2D v = {_velocity.x,_velocity.y}; return v; } +// Function used to fetch the current position of the instagram icon Vector2D Insta::get_pos() { Vector2D p = {_x,_y}; return p; } +// Function used to set the current position of the instagram icon void Insta::set_pos(Vector2D p) { _x = p.x;