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
Diff: spaceship/space_ship.cpp
- Revision:
- 93:ab36428d0152
- Parent:
- 92:8a1b14488ca5
diff -r 8a1b14488ca5 -r ab36428d0152 spaceship/space_ship.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/spaceship/space_ship.cpp Sun May 05 01:28:52 2019 +0000
@@ -0,0 +1,63 @@
+#include "space_ship.h"
+
+space_ship::space_ship()
+{
+
+}
+
+space_ship::~space_ship()
+{
+
+}
+
+
+
+
+const int space_ship[10][12]= {
+ {0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,1,1,0,0,0,0,0,0,0},
+ {0,0,0,1,1,0,0,0,0,0,0,0},
+ {0,1,1,1,1,1,1,1,0,0,0,0},
+ {0,1,1,1,1,1,1,1,1,0,0,0},
+ {0,1,1,1,1,1,1,1,1,1,1,0},
+ {0,1,1,1,1,1,1,1,1,0,0,0},
+ {0,1,1,1,1,1,1,1,0,0,0,0},
+ {0,0,0,1,1,0,0,0,0,0,0,0},
+ {0,0,0,1,1,0,0,0,0,0,0,0},
+
+};
+
+void space_ship::init(int x,int height,int width)
+{
+ _x = x; // x value on screen is fixed
+ _y = HEIGHT/2 - height/2; // y depends on height of screen and height of space_ship
+ _height = height;
+ _width = width;
+ _speed = 1; // default speed
+ _score = 0; // start score from zero
+
+
+
+}
+
+void space_ship::draw(N5110 &lcd)
+{
+ // draw space_ship in screen buffer.
+ lcd.drawSprite(x_space_ship,y_space_ship,10,12,(int *) space_ship);
+}
+
+void space_ship::add_score()
+{
+ _score++;
+}
+
+int space_ship::get_score()
+{
+ return _score;
+}
+
+Vector2D space_ship::get_pos()
+{
+ Vector2D p = {_x,_y};
+ return p;
+}
\ No newline at end of file