ELEC2645 (2019/20)
/
ELEC2645_Project_el18vgt
Game designed for project
Diff: MyClasses/PaddleControl.cpp
- Revision:
- 3:5ede4ac61af1
- Parent:
- 2:e67ca889c81b
--- a/MyClasses/PaddleControl.cpp Tue May 19 09:51:13 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ - -#include "PaddleControl.h" - - -void Paddle::init(int y,int length,int height) -{ - _y = y; // x value on screen is fixed - _x = WIDTH/2 - length/2; // y depends on height of screen and height of paddle - _height = height; - _length = length; - _speed = 1; // default speed -} - -void Paddle::print_lcd(N5110 &lcd) -{ - lcd.drawRect(_x,_y,_width,_height,FILL_BLACK); -} - -void Paddle::update(char direction) -{ - if (direction == 'R') { - _x-=_speed; - } else if (direction == 'L') { - _x+=_speed; - } - - if (_x < 1) { - _x = 1; - } - if (_x > WIDTH - _length - 1) { - _x = WIDTH - _length - 1; - } -} - -Vector2D Paddle::get_pos() { - Vector2D p = {_x,_y}; - return p; -} \ No newline at end of file