4 * Created on: Apr 10, 2012
17 Paddle::Paddle(Scalar width, Scalar height)
18 : Entity(&shape, std::numeric_limits<Scalar>::infinity())
19 , shape(width, height) {
24 void Paddle::Collide(Entity &other, const Ray &) {
25 if (dynamic_cast<Ball *>(&other)) {
26 Vector distance(other.Origin() - Origin());
27 other.Accelerate(distance.Unit() * 5);
31 void Paddle::Render(SDL_Surface *screen) const {
33 destRect.x = shape.Left();
34 destRect.y = shape.Top();
35 destRect.w = shape.Width();
36 destRect.h = shape.Height();
37 SDL_FillRect(screen, &destRect, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));
41 void Paddle::SetMovementSpeed(Vector s) {
42 // Vector d(s - movementSpeed);
48 void Paddle::StartMovingUp(void) {
49 Accelerate(-movementSpeed);
52 void Paddle::StopMovingUp(void) {
53 Accelerate(movementSpeed);
56 void Paddle::StartMovingDown(void) {
57 Accelerate(movementSpeed);
60 void Paddle::StopMovingDown(void) {
61 Accelerate(-movementSpeed);