![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Simple Pong game on NokiaLCD with PS2
Dependencies: mbed PS2 NokiaLCD
Diff: paddle.cpp
- Revision:
- 1:3cc8b1413557
- Parent:
- 0:93dce1e528b9
diff -r 93dce1e528b9 -r 3cc8b1413557 paddle.cpp --- a/paddle.cpp Sun Feb 27 23:35:17 2011 +0000 +++ b/paddle.cpp Mon Feb 28 00:12:36 2011 +0000 @@ -9,14 +9,27 @@ 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(NokiaLCD &lcd, int increment) { - lcd.fill(x,y,width,height, 0x000000); + 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(NokiaLCD &lcd, int _y) { static int inc = 1; - lcd.fill(x,y,width,height, 0x000000); + draw(lcd, true); 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;