-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPaddle.cpp
More file actions
27 lines (23 loc) · 908 Bytes
/
Paddle.cpp
File metadata and controls
27 lines (23 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "stdafx.h"
#include "Paddle.h"
Paddle::Paddle(){};
Paddle::Paddle(sf::Keyboard::Key upKey, sf::Keyboard::Key downKey, sf::Vector2f size, sf::Color colour, sf::Color outlineColour, int outlineThickness, sf::Vector2f position, sf::Vector2f origin) {
paddleUpKey = upKey;
paddleDownKey = downKey;
this->setSize(size);
this->setFillColor(colour);
this->setOutlineColor(outlineColour);
this->setOutlineThickness(outlineThickness);
this->setPosition(position);
this->setOrigin(origin);
}
void Paddle::ReadInput(const Wall &ceiling, const Wall &floor, const float &factor) {
if (sf::Keyboard::isKeyPressed(paddleUpKey) && !(this->getGlobalBounds().intersects(ceiling.getGlobalBounds())))
{
this->move(0.f, -factor); //Move in Y Plane only
}
if (sf::Keyboard::isKeyPressed(paddleDownKey) && !(this->getGlobalBounds().intersects(floor.getGlobalBounds())))
{
this->move(0.f, factor);
}
}