Laila Al Badwawi 200906179 SpaceInvaders I declare this my own independent work and understand the university rules on plagiarism.

Dependencies:   mbed

Revision:
138:66befaefb27e
Child:
139:c46a2cef7e09
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Spaceship/Spaceship.cpp	Thu May 09 05:42:22 2019 +0000
@@ -0,0 +1,74 @@
+#include "Spaceship.h"
+
+Spaceship::Spaceship()
+{
+}
+Spaceship::~Spaceship()
+{
+}
+
+void Spaceship::init(int x_spaceship,int y_spaceship, int speed_spaceship)
+{
+
+     _x_spaceship=  x_spaceship;
+     _y_spaceship=  y_spaceship;
+      _speed_spaceship= speed_spaceship;
+}
+
+void Spaceship::draw(N5110 &lcd)
+{
+
+    lcd.drawSprite(_x_spaceship,_y_spaceship,32,32,(int *) spaceship2);
+
+}
+
+
+void Spaceship::update(Direction d,float mag)
+{
+    _speed_spaceship = int(mag*10.0f);
+
+        if(d==N){
+   //  printf("North\n");
+            _y_spaceship-=2;
+            }
+        else
+        if(d==S){
+               //  printf("North\n");
+            _y_spaceship+=2;
+
+            }
+
+        if(_y_spaceship>=30){
+            _y_spaceship=30;
+            }
+        else
+        if(_y_spaceship<=0){
+            _y_spaceship=0;
+            }
+
+}
+
+int Spaceship::get_pos_x()
+{
+    return _x_spaceship;
+}
+int Spaceship::get_pos_y()
+{
+    return _y_spaceship;
+}
+
+void Spaceship::set_pos(int x, int y)
+{
+    _x_spaceship = x;
+    _y_spaceship = y;
+}
+
+void Spaceship::add_score()
+{
+    _score++;
+}
+
+int Spaceship::get_score()
+{
+    return _score;
+}
\ No newline at end of file