ST7735 Pong by Jonne Valola, derived work from William Johnston\'s mbed Pong for NokiaLCD / PS2 keyboard This pong uses a rotary encoder hooked to pins 21 and 22, ST7735_TFT library by me, RotaryEncoder library by Shinichiro Nakamura. All copyrights of respective owners. Use on your own risk and discretion.

Dependencies:   mbed ST7735_TFT RotaryEncoder TFT_fonts_old

Revision:
0:2353da390056
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paddle.cpp	Mon Dec 12 21:35:42 2011 +0000
@@ -0,0 +1,80 @@
+#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) {}
+ 
+/* 
+ * Member Function move:
+ * Description: Colors in the previous paddle black
+ *  and moves paddle to new position.
+ */
+void Paddle::move(ST7735_TFT &lcd, int increment) {
+  draw(lcd, true);
+  y += increment;
+}
+
+
+/* 
+ * Member Function moveCPU:
+ * Description: Colors in the previous paddle black
+ *  and moves paddle to new position.
+ *  inc variable allows paddle to only move every
+ *  other function call.
+ */
+void Paddle::moveCPU(ST7735_TFT &lcd, int _y) {
+  static int inc = 1;
+  draw(lcd, true);
+  if(_y>y+height/2 && y+height<128) y += inc;
+  else if(_y+5<y+height/2 && y>0) y -= inc;
+  inc = (inc) ? 0 : 1;
+}
+
+void Paddle::draw(ST7735_TFT &lcd, bool isBlack) const {
+  lcd.fillrect(x, y, x + width, y + 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