//constructor
Paddle::Paddle(int player) {
//set up the starting position
if(player == 1) {
//left hand player
x = 1;
} else {
//right hand player
x = 80;
}
//collision detection
bool
Paddle::checkCollision(Ball b) {
//TODO: Check Collision
}
//screen commands
void
Paddle::draw() {
//set the background color
cout << whiteBackground;
//loop over every spot on the paddle
for(int sy = y - PADDLE_HEIGHT/2; sy < y+PADDLE_HEIGHT/2; sy++) {
cout << cursorPosition(x, sy) << ' ';
}
//set it back
cout << normal;
cout.flush();
}
void
Paddle::erase() {
//erase with normal
cout << normal;
//loop over every spot on the paddle
for(int sy = y - PADDLE_HEIGHT/2; sy < y+PADDLE_HEIGHT/2; sy++) {
cout << cursorPosition(x, sy) << ' ';
}
cout.flush();
}
void
Paddle::update() {
//TODO: Update
}
int
Paddle::getX() {
return x;
}
int
Paddle::getY() {
return y;
}
//////////////////////////////////////////////////
// Player Paddle
//////////////////////////////////////////////////
PlayerPaddle::PlayerPaddle(int player) : Paddle(player) {
}
void
PlayerPaddle::update() {
char c;
//no can move if not has input
if(!hasInput())
return;
//get the key press
c = cin.get();
//process the keypress
switch(c) {
case 'k':
case 'w':
moveUp();
break;