ELEC2645 (2018/19) / Mbed 2 deprecated el17rrrs

Dependencies:   mbed Gamepad N5110 mbed-rtos

Revision:
0:d9cf94b41df3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Background/Background.cpp	Thu May 09 09:49:35 2019 +0000
@@ -0,0 +1,120 @@
+#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;
+}
\ No newline at end of file