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 Gamepad N5110 mbed-rtos
Background/Background.cpp
- Committer:
- RexRoshan
- Date:
- 2019-05-09
- Revision:
- 0:d9cf94b41df3
File content as of revision 0:d9cf94b41df3:
#include "Background.h" // nothing doing in the constructor and destructor Background::Background() { } Background::~Background() { } // upper cloud int upper_cloud [18][16] = { {1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0}, {1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0}, {0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0}, {0,1,1,0,0,1,0,0,1,0,0,0,0,0,0,0}, {0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0}, {0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0}, {0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0}, {0,1,1,0,0,1,0,1,0,0,0,0,0,0,0,0}, {1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0}, {1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0}, {1,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0}, {0,1,1,1,0,0,0,0,0,0,1,0,1,0,0,0}, {0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0}, {0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, {0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0}, {0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0}, {0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0}, }; int lower_cloud [16][17] = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1}, {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1}, {0,0,0,1,1,1,0,0,0,0,0,0,0,1,0,1,0}, {0,0,1,1,0,0,1,0,0,0,0,0,0,1,0,1,0}, {0,1,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0}, {1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0}, {1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0}, {1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0}, {0,1,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0}, {0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0}, {0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0}, {1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0}, {1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0}, {0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0}, }; void Background::init_u(int a,int b) // initialising the x and y position of the clouds { _a = a; // x position of the upper cloud _b = b; // y position of the upper cloud } void Background::init_l(int c,int d) // initialising the x and y position of the clouds { _c = c; // x position of the lower cloud _d = d; // y position of the lower cloud } void Background::background(N5110 &lcd) { // Draws the clouds lcd.drawSprite(_a,_b,18,16,(int *)upper_cloud); lcd.drawSprite(_c, _d, 16, 17, (int *)lower_cloud); } void Background::update() // Moves the position of the cloud everytime { _fast = 1.0; // Movement speed = 1 so that it is not too fast _a+=_fast; _c+=_fast; // moves the x-position to the right } Vector2D Background::get_pos_upper() { //gets the position of the clouds Vector2D e = {_a,_b}; return e; } Vector2D Background::get_pos_lower() { //gets the position of the clouds Vector2D f = {_c,_d}; return f; } void Background::set_pos_upper(Vector2D e) { //sets the position of the first enemy of stage 2 _a = e.x; _b = e.y; } void Background::set_pos_lower(Vector2D f) { //sets the position of the first enemy of stage 2 _c = f.x; _d = f.y; }