Game codes for Pokemon Academy Yiu Fai Kwok - 201198802 I have read the University Regulations on Plagiarism and state that the work covered by this declaration is my own and does not contain any unacknowledged work from other sources.
Dependencies: mbed FXOS8700CQ mbed-rtos
Diff: Game_two/Twitter_files/Twitter.cpp
- Revision:
- 33:f7ec806e14b6
- Parent:
- 26:c60becf3f840
--- a/Game_two/Twitter_files/Twitter.cpp Wed May 08 15:14:55 2019 +0000 +++ b/Game_two/Twitter_files/Twitter.cpp Wed May 08 23:57:04 2019 +0000 @@ -10,6 +10,7 @@ } +// Function to initiate the twitter icon void Twitter::init(int speed) { int position = rand() % 8; // randomise initial direction and position. @@ -58,6 +59,7 @@ } } +// Draw the twitter icon depending on the updated position void Twitter::draw(N5110 &lcd) { int Twitter_data[12][12] = { @@ -78,30 +80,35 @@ lcd.drawSprite(_x, _y, 12, 12, (int*)Twitter_data); } +// Update the position of the twitter icon dependent on the speed void Twitter::update() { _x += _velocity.x; _y += _velocity.y; } +// Function used to set the velocity of the twitter icon void Twitter::set_velocity(Vector2D v) { _velocity.x = v.x; _velocity.y = v.y; } +// Function used to fetch the current velocity of the twitter icon Vector2D Twitter::get_velocity() { Vector2D v = {_velocity.x,_velocity.y}; return v; } +// Function used to fetch the current position of the twitter icon Vector2D Twitter::get_pos() { Vector2D p = {_x,_y}; return p; } +// Function used to set the current position of the twitter icon void Twitter::set_pos(Vector2D p) { _x = p.x;