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
Fork of el17zl by
Diff: Ppl/Ppl.cpp
- Revision:
- 3:9fa31396d89d
- Child:
- 4:750d3f9b54de
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Ppl/Ppl.cpp Sun Mar 24 22:41:22 2019 +0000
@@ -0,0 +1,65 @@
+#include "Ppl.h"
+
+const int ppl[8][8]= {
+ {0,0,0,0,1,1,1,0},
+ {0,0,0,0,1,0,1,0},
+ {0,0,0,0,1,1,1,0},
+ {1,0,0,0,0,1,0,0},
+ {0,1,1,0,0,1,0,0},
+ {0,0,0,1,1,1,0,0},
+ {0,0,0,0,0,1,0,0},
+ {0,0,0,1,1,0,1,1},
+
+};
+
+Ppl::Ppl()
+{
+
+}
+
+Ppl::~Ppl()
+{
+
+}
+
+void Ppl::init(int x0, int y0)
+{
+ _x = x0;
+ _y = y0;
+
+}
+
+void Ppl::draw(N5110 &lcd)
+{
+ lcd.drawSprite(_x,_y,8,8,(int *)ppl);
+}
+
+void Ppl::update()
+{
+
+ // check the y origin to ensure that the paddle doesn't go off screen
+ if (_y < 4) {
+ _y = 4;
+ }
+ if (_y > 37) {
+ _y = 37;
+ }
+ if (_x > 75) {
+ _x = 75;
+ }
+ if (_x < 2) {
+ _x = 2;
+ }
+}
+
+Vector2D Ppl::get_pos()
+{
+ Vector2D p = {_x,_y};
+ return p;
+}
+
+void Ppl::set_pos(Vector2D p)
+{
+ _x = p.x;
+ _y = p.y;
+}
\ No newline at end of file
