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 PS2 NokiaLCD
Diff: paddle.cpp
- Revision:
- 0:93dce1e528b9
- Child:
- 1:3cc8b1413557
diff -r 000000000000 -r 93dce1e528b9 paddle.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/paddle.cpp Sun Feb 27 23:35:17 2011 +0000
@@ -0,0 +1,67 @@
+#include "mbed.h"
+#include "paddle.h"
+
+Paddle::Paddle() {
+ int x=y=width=height=color=score=0;
+ lives = 3;
+}
+
+Paddle::Paddle(int x, int y, int w, int h, int c, int l, int s)
+ : x(x), y(y), width(w), height(h), color(c), lives(l), score(s) {}
+
+void Paddle::move(NokiaLCD &lcd, int increment) {
+ lcd.fill(x,y,width,height, 0x000000);
+ y += increment;
+}
+
+void Paddle::moveCPU(NokiaLCD &lcd, int _y) {
+ static int inc = 1;
+ lcd.fill(x,y,width,height, 0x000000);
+ if(_y>y+height/2 && y+height<130) y += inc;
+ else if(_y+5<y+height/2 && y>0) y -= inc;
+ inc = (inc) ? 0 : 1;
+}
+
+void Paddle::draw(NokiaLCD &lcd, bool isBlack) const {
+ lcd.fill(x, y, width, height, (isBlack) ? 0x000000 : color);
+}
+
+bool Paddle::loseLife() {
+ return --lives;
+}
+
+void Paddle::addPoint() {
+ ++score;
+}
+
+int Paddle::size() const {
+ return width*height;
+}
+
+int Paddle::getWidth() const {
+ return width;
+}
+
+int Paddle::getHeight() const {
+ return height;
+}
+
+int Paddle::getX() const {
+ return x;
+}
+
+int Paddle::getY() const {
+ return y;
+}
+
+int Paddle::getLives() const {
+ return lives;
+}
+
+int Paddle::getScore() const {
+ return score;
+}
+
+void Paddle::setLives(int l) {
+ lives = l;
+}
\ No newline at end of file